@trycourier/react-designer 0.0.0-canary-20251202152218 → 0.0.0-canary-20251204163023

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -43,7 +43,7 @@ if (typeof require !== "undefined") {
43
43
  console.warn('Unable to setup tippy imports polyfill');
44
44
  }
45
45
  }
46
- "use strict";var i2=Object.create;var La=Object.defineProperty;var a2=Object.getOwnPropertyDescriptor;var s2=Object.getOwnPropertyNames;var l2=Object.getPrototypeOf,c2=Object.prototype.hasOwnProperty;var a=(e,t)=>La(e,"name",{value:t,configurable:!0});var Cu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),u2=(e,t)=>{for(var r in t)La(e,r,{get:t[r],enumerable:!0})},hp=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of s2(t))!c2.call(e,n)&&n!==r&&La(e,n,{get:()=>t[n],enumerable:!(o=a2(t,n))||o.enumerable});return e};var Ae=(e,t,r)=>(r=e!=null?i2(l2(e)):{},hp(t||!e||!e.__esModule?La(r,"default",{value:e,enumerable:!0}):r,e)),d2=e=>hp(La({},"__esModule",{value:!0}),e);var Vd=Cu(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});gl.bind=void 0;function _2(e,t){var r=t.type,o=t.listener,n=t.options;return e.addEventListener(r,o,n),a(function(){e.removeEventListener(r,o,n)},"unbind")}a(_2,"bind");gl.bind=_2});var Of=Cu(oa=>{"use strict";var ra=oa&&oa.__assign||function(){return ra=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},ra.apply(this,arguments)};Object.defineProperty(oa,"__esModule",{value:!0});oa.bindAll=void 0;var $2=Vd();function Vf(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}a(Vf,"toOptions");function j2(e,t){if(t==null)return e;var r=ra(ra({},e),{options:ra(ra({},Vf(t)),Vf(e.options))});return r}a(j2,"getBinding");function Z2(e,t,r){var o=t.map(function(n){var i=j2(n,r);return(0,$2.bind)(e,i)});return a(function(){o.forEach(function(i){return i()})},"unbindAll")}a(Z2,"bindAll");oa.bindAll=Z2});var es=Cu(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.bindAll=na.bind=void 0;var q2=Vd();Object.defineProperty(na,"bind",{enumerable:!0,get:function(){return q2.bind}});var J2=Of();Object.defineProperty(na,"bindAll",{enumerable:!0,get:function(){return J2.bindAll}})});var Yv={};u2(Yv,{BrandEditor:()=>lp,BrandFooter:()=>wa,BrandProvider:()=>bp,CHANNELS:()=>Pn,ChannelRootContainer:()=>Un,EditorSidebar:()=>zn,EmailChannel:()=>jv,EmailEditor:()=>Zc,EmailEditorContainer:()=>Qm,EmailEditorMain:()=>ep,EmailSideBar:()=>Jc,EmailSideBarItemDetails:()=>Gc,ErrorBoundary:()=>Qs,InboxChannel:()=>Jv,InboxEditor:()=>Yc,InboxSideBar:()=>Qc,MSTeamsChannel:()=>Gv,MSTeamsEditor:()=>gu,MSTeamsSideBar:()=>hu,MonacoCodeEditor:()=>Kl,PreviewPanel:()=>$c,PushChannel:()=>qv,PushEditor:()=>ru,SMSChannel:()=>Zv,SMSEditor:()=>du,SlackChannel:()=>Kv,SlackEditor:()=>au,SlackSideBar:()=>su,SlackSideBarItemDetails:()=>lu,TemplateEditor:()=>$v,TemplateProvider:()=>xp,TemplateStatus:()=>ea,TextMenu:()=>zc,ToggleGroup:()=>er,apiUrlAtom:()=>sr,brandApplyAtom:()=>xu,cn:()=>R,convertElementalToTiptap:()=>Qe,convertLegacyError:()=>Ra,convertTiptapToElemental:()=>Te,createCustomError:()=>Oo,extractErrorMessage:()=>b2,isRetryableError:()=>h2,isTemplateLoadingAtom:()=>be,isTemplatePublishingAtom:()=>cr,isTemplateSavingAtom:()=>Ot,templateDataAtom:()=>Tt,templateErrorAtom:()=>ae,templateIdAtom:()=>go,tenantIdAtom:()=>Vt,tokenAtom:()=>lr,useAutoSave:()=>Na,useBrandActions:()=>Wi,useChannels:()=>bu,useDebouncedFlush:()=>Xc,useImageUpload:()=>zi,useNodeAttributes:()=>zt,useTemplateActions:()=>Ui,useTemplateStore:()=>Bi,useVariables:()=>v0});module.exports=d2(Yv);var Tn=require("jotai"),Hi=require("react");var fo=require("jotai"),sr=(0,fo.atom)("https://api.courier.com/client/q"),lr=(0,fo.atom)(""),Vt=(0,fo.atom)(""),go=(0,fo.atom)(""),Tt=(0,fo.atom)(null),be=(0,fo.atom)(null),Ot=(0,fo.atom)(null),cr=(0,fo.atom)(null),ae=(0,fo.atom)(null),xu=(0,fo.atom)(!0);var Di=require("react/jsx-runtime"),m2=a(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=(0,Tn.useAtom)(sr),[,i]=(0,Tn.useAtom)(lr),[,s]=(0,Tn.useAtom)(Vt);return(0,Hi.useEffect)(()=>{i(r),s(t),o&&n(o)},[r,t,o,n,i,s]),(0,Di.jsx)(Di.Fragment,{children:e})},"BrandProviderContext"),p2=a(e=>{let t=(0,Hi.useMemo)(()=>(0,Tn.createStore)(),[]);return(0,Di.jsx)(Tn.Provider,{store:t,children:(0,Di.jsx)(m2,{...e})})},"BrandProviderComponent"),bp=(0,Hi.memo)(p2);var eo=require("jotai"),ho=require("react"),yp=require("sonner");var $s=require("react/jsx-runtime"),Bi=a(()=>({store:(0,eo.useStore)()}),"useTemplateStore"),vp=(0,ho.createContext)(null),Cp=a(()=>(0,ho.useContext)(vp),"useUploadImage"),f2=a(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,s]=(0,eo.useAtom)(sr),[,l]=(0,eo.useAtom)(lr),[,c]=(0,eo.useAtom)(Vt),[,u]=(0,eo.useAtom)(go),[d]=(0,eo.useAtom)(ae);return(0,ho.useEffect)(()=>{l(o),c(r),u(t),n&&s(n)},[o,r,t,n,s,l,c,u]),(0,ho.useEffect)(()=>{d&&yp.toast.error(d.message,d.toastProps)},[d]),(0,$s.jsx)(vp.Provider,{value:i||null,children:e})},"TemplateProviderContext"),g2=a(e=>{let t=(0,ho.useMemo)(()=>(0,eo.createStore)(),[]);return(0,$s.jsx)(eo.Provider,{store:t,children:(0,$s.jsx)(f2,{...e})})},"TemplateProviderComponent"),xp=(0,ho.memo)(g2);var yo=require("jotai");var Oo=a((e,t)=>({message:e,toastProps:t}),"createCustomError"),h2=a(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),b2=a(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),Ra=a(e=>typeof e=="string"?Oo(e):e,"convertLegacyError");var Tu=require("jotai"),Tp=require("sonner");var wp=(0,Tu.atom)(null,async(e,t,r)=>{var s;let o=e(sr),n=e(lr),i=e(Vt);if(!o){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ot,!0),t(ae,null);try{let c=await(await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
46
+ "use strict";var Gb=Object.create;var Pa=Object.defineProperty;var Kb=Object.getOwnPropertyDescriptor;var Yb=Object.getOwnPropertyNames;var Xb=Object.getPrototypeOf,Qb=Object.prototype.hasOwnProperty;var a=(e,t)=>Pa(e,"name",{value:t,configurable:!0});var gu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),e2=(e,t)=>{for(var r in t)Pa(e,r,{get:t[r],enumerable:!0})},np=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Yb(t))!Qb.call(e,n)&&n!==r&&Pa(e,n,{get:()=>t[n],enumerable:!(o=Kb(t,n))||o.enumerable});return e};var Ae=(e,t,r)=>(r=e!=null?Gb(Xb(e)):{},np(t||!e||!e.__esModule?Pa(r,"default",{value:e,enumerable:!0}):r,e)),t2=e=>np(Pa({},"__esModule",{value:!0}),e);var Rd=gu(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.bind=void 0;function D2(e,t){var r=t.type,o=t.listener,n=t.options;return e.addEventListener(r,o,n),a(function(){e.removeEventListener(r,o,n)},"unbind")}a(D2,"bind");dl.bind=D2});var Mf=gu(Ki=>{"use strict";var Gi=Ki&&Ki.__assign||function(){return Gi=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Gi.apply(this,arguments)};Object.defineProperty(Ki,"__esModule",{value:!0});Ki.bindAll=void 0;var B2=Rd();function kf(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}a(kf,"toOptions");function H2(e,t){if(t==null)return e;var r=Gi(Gi({},e),{options:Gi(Gi({},kf(t)),kf(e.options))});return r}a(H2,"getBinding");function F2(e,t,r){var o=t.map(function(n){var i=H2(n,r);return(0,B2.bind)(e,i)});return a(function(){o.forEach(function(i){return i()})},"unbindAll")}a(F2,"bindAll");Ki.bindAll=F2});var Ga=gu(Yi=>{"use strict";Object.defineProperty(Yi,"__esModule",{value:!0});Yi.bindAll=Yi.bind=void 0;var V2=Rd();Object.defineProperty(Yi,"bind",{enumerable:!0,get:function(){return V2.bind}});var O2=Mf();Object.defineProperty(Yi,"bindAll",{enumerable:!0,get:function(){return O2.bindAll}})});var zv={};e2(zv,{BrandEditor:()=>op,BrandFooter:()=>ha,BrandProvider:()=>ip,CHANNELS:()=>Cn,ChannelRootContainer:()=>Vn,EditorSidebar:()=>On,EmailChannel:()=>Hv,EmailEditor:()=>zc,EmailEditorContainer:()=>Jm,EmailEditorMain:()=>Gm,EmailSideBar:()=>$c,EmailSideBarItemDetails:()=>jc,ErrorBoundary:()=>Gs,InboxChannel:()=>Ov,InboxEditor:()=>qc,InboxSideBar:()=>Gc,MSTeamsChannel:()=>Wv,MSTeamsEditor:()=>du,MSTeamsSideBar:()=>mu,MonacoCodeEditor:()=>Zl,PreviewPanel:()=>Wc,PushChannel:()=>Vv,PushEditor:()=>Xc,SMSChannel:()=>Fv,SMSEditor:()=>su,SlackChannel:()=>Uv,SlackEditor:()=>ru,SlackSideBar:()=>ou,SlackSideBarItemDetails:()=>nu,TemplateEditor:()=>Bv,TemplateProvider:()=>cp,TemplateStatus:()=>qi,TextMenu:()=>Vc,ToggleGroup:()=>er,apiUrlAtom:()=>ar,brandApplyAtom:()=>hu,cn:()=>D,convertElementalToTiptap:()=>Qe,convertLegacyError:()=>ka,convertTiptapToElemental:()=>Ce,createCustomError:()=>Fo,extractErrorMessage:()=>s2,isRetryableError:()=>a2,isTemplateLoadingAtom:()=>ge,isTemplatePublishingAtom:()=>lr,isTemplateSavingAtom:()=>Ot,templateDataAtom:()=>Tt,templateErrorAtom:()=>ae,templateIdAtom:()=>uo,tenantIdAtom:()=>Vt,tokenAtom:()=>sr,useAutoSave:()=>xa,useBrandActions:()=>Ri,useChannels:()=>pu,useDebouncedFlush:()=>Jc,useImageUpload:()=>Bi,useNodeAttributes:()=>zt,useTemplateActions:()=>Di,useTemplateStore:()=>Ni,useVariables:()=>u0});module.exports=t2(zv);var bn=require("jotai"),Ai=require("react");var co=require("jotai"),ar=(0,co.atom)("https://api.courier.com/client/q"),sr=(0,co.atom)(""),Vt=(0,co.atom)(""),uo=(0,co.atom)(""),Tt=(0,co.atom)(null),ge=(0,co.atom)(null),Ot=(0,co.atom)(null),lr=(0,co.atom)(null),ae=(0,co.atom)(null),hu=(0,co.atom)(!0);var Mi=require("react/jsx-runtime"),r2=a(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=(0,bn.useAtom)(ar),[,i]=(0,bn.useAtom)(sr),[,s]=(0,bn.useAtom)(Vt);return(0,Ai.useEffect)(()=>{i(r),s(t),o&&n(o)},[r,t,o,n,i,s]),(0,Mi.jsx)(Mi.Fragment,{children:e})},"BrandProviderContext"),o2=a(e=>{let t=(0,Ai.useMemo)(()=>(0,bn.createStore)(),[]);return(0,Mi.jsx)(bn.Provider,{store:t,children:(0,Mi.jsx)(r2,{...e})})},"BrandProviderComponent"),ip=(0,Ai.memo)(o2);var Xr=require("jotai"),mo=require("react"),ap=require("sonner");var Vs=require("react/jsx-runtime"),Ni=a(()=>({store:(0,Xr.useStore)()}),"useTemplateStore"),sp=(0,mo.createContext)(null),lp=a(()=>(0,mo.useContext)(sp),"useUploadImage"),n2=a(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,s]=(0,Xr.useAtom)(ar),[,l]=(0,Xr.useAtom)(sr),[,c]=(0,Xr.useAtom)(Vt),[,u]=(0,Xr.useAtom)(uo),[d]=(0,Xr.useAtom)(ae);return(0,mo.useEffect)(()=>{l(o),c(r),u(t),n&&s(n)},[o,r,t,n,s,l,c,u]),(0,mo.useEffect)(()=>{d&&ap.toast.error(d.message,d.toastProps)},[d]),(0,Vs.jsx)(sp.Provider,{value:i||null,children:e})},"TemplateProviderContext"),i2=a(e=>{let t=(0,mo.useMemo)(()=>(0,Xr.createStore)(),[]);return(0,Vs.jsx)(Xr.Provider,{store:t,children:(0,Vs.jsx)(n2,{...e})})},"TemplateProviderComponent"),cp=(0,mo.memo)(i2);var fo=require("jotai");var Fo=a((e,t)=>({message:e,toastProps:t}),"createCustomError"),a2=a(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),s2=a(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),ka=a(e=>typeof e=="string"?Fo(e):e,"convertLegacyError");var bu=require("jotai"),up=require("sonner");var dp=(0,bu.atom)(null,async(e,t,r)=>{var s;let o=e(ar),n=e(sr),i=e(Vt);if(!o){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ot,!0),t(ae,null);try{let c=await(await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
47
47
  mutation SaveTenantBrand($input: SaveBrandSettingsInput!) {
48
48
  tenant {
49
49
  brand {
@@ -54,7 +54,7 @@ if (typeof require !== "undefined") {
54
54
  }
55
55
  }
56
56
  `,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(s=c.errors)==null?void 0:s.map(d=>d.message);t(ae,{message:u.join(`
57
- `),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(Ot,!1)}}),Ep=(0,Tu.atom)(null,async(e,t)=>{let r=e(sr),o=e(lr),n=e(Vt);if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(cr,!0),t(ae,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
57
+ `),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(Ot,!1)}}),mp=(0,bu.atom)(null,async(e,t)=>{let r=e(ar),o=e(sr),n=e(Vt);if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(lr,!0),t(ae,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
58
58
  mutation PublishNotification($input: PublishBrandInput!) {
59
59
  tenant {
60
60
  brand {
@@ -64,7 +64,7 @@ if (typeof require !== "undefined") {
64
64
  }
65
65
  }
66
66
  }
67
- `,variables:{input:{tenantId:n}}})}),s=await i.json();return i.status===200?Tp.toast.success("Brand published"):t(ae,{message:"Error publishing brand",toastProps:{duration:4e3}}),s}catch(i){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(cr,!1)}});var Mp=require("jotai");var Wt=require("jotai");var Yn=(0,Wt.atom)(null),Eu=(0,Wt.atom)(null),js=(0,Wt.atom)(null),se=(0,Wt.atom)(e=>e(js),(e,t,r)=>{if(!r){t(js,r);return}let o=e(Eu),n=r;if(o)try{n=o(r)}catch(s){console.error("[ContentTransformer] Error applying transformer:",s),n=r}let i=e(js);JSON.stringify(i)!==JSON.stringify(n)&&t(js,n)}),Fi=(0,Wt.atom)(null),Vi=(0,Wt.atom)(null),_e=(0,Wt.atom)(null),Oi=(0,Wt.atom)(null),Ut=(0,Wt.atom)(!1),Wo=(0,Wt.atom)(!1),Xn=(0,Wt.atom)({}),Cr=(0,Wt.atom)(!1),wt=(0,Wt.atom)(null),Pp=(0,Wt.atom)(null),wu=(0,Wt.atom)(new Map),Qn=(0,Wt.atom)(e=>e(wu),(e,t,r)=>{let o=new Map(e(wu));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(wu,o)}),kp=a(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates");var Zs=(0,Mp.atom)(null,async(e,t,r)=>{var c,u,d,f,m;let o=e(sr),n=e(lr),i=e(Vt),s=e(go),l=(c=r==null?void 0:r.includeBrand)!=null?c:!0;if(!o||!n||!i){let p=[];o||p.push("API URL"),n||p.push("token"),i||p.push("tenant ID"),t(ae,{message:"Missing configuration",toastProps:{description:`Missing: ${p.join(", ")}`,duration:5e3}});return}t(be,!0),t(ae,null);try{let p=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`},body:JSON.stringify({query:`
67
+ `,variables:{input:{tenantId:n}}})}),s=await i.json();return i.status===200?up.toast.success("Brand published"):t(ae,{message:"Error publishing brand",toastProps:{duration:4e3}}),s}catch(i){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(lr,!1)}});var gp=require("jotai");var Wt=require("jotai");var Zn=(0,Wt.atom)(null),vu=(0,Wt.atom)(null),Os=(0,Wt.atom)(null),se=(0,Wt.atom)(e=>e(Os),(e,t,r)=>{if(!r){t(Os,r);return}let o=e(vu),n=r;if(o)try{n=o(r)}catch(s){console.error("[ContentTransformer] Error applying transformer:",s),n=r}let i=e(Os);JSON.stringify(i)!==JSON.stringify(n)&&t(Os,n)}),Si=(0,Wt.atom)(null),Ii=(0,Wt.atom)(null),ze=(0,Wt.atom)(null),Li=(0,Wt.atom)(null),Ut=(0,Wt.atom)(!1),Vo=(0,Wt.atom)(!1),qn=(0,Wt.atom)({}),vr=(0,Wt.atom)(!1),lt=(0,Wt.atom)(null),pp=(0,Wt.atom)(null),yu=(0,Wt.atom)(new Map),Jn=(0,Wt.atom)(e=>e(yu),(e,t,r)=>{let o=new Map(e(yu));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(yu,o)}),fp=a(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates");var Ws=(0,gp.atom)(null,async(e,t,r)=>{var c,u,d,f,m;let o=e(ar),n=e(sr),i=e(Vt),s=e(uo),l=(c=r==null?void 0:r.includeBrand)!=null?c:!0;if(!o||!n||!i){let p=[];o||p.push("API URL"),n||p.push("token"),i||p.push("tenant ID"),t(ae,{message:"Missing configuration",toastProps:{description:`Missing: ${p.join(", ")}`,duration:5e3}});return}t(ge,!0),t(ae,null);try{let p=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`},body:JSON.stringify({query:`
68
68
  query GetTenant($tenantId: String!, $input: GetNotificationInput!, $brandInput: GetTenantBrandInput!, $includeBrand: Boolean!) {
69
69
  tenant(tenantId: $tenantId) {
70
70
  tenantId
@@ -122,13 +122,13 @@ if (typeof require !== "undefined") {
122
122
  }
123
123
  }
124
124
  }
125
- `,variables:{tenantId:i,input:{notificationId:s,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),v=await p.json(),h=p.status,g=(u=v.data)==null?void 0:u.tenant;if(g?(t(Tt,v),t(Fi,(d=g==null?void 0:g.notification)==null?void 0:d.publishedAt),t(Vi,(f=g==null?void 0:g.notification)==null?void 0:f.version)):h===401?t(ae,{message:"Authentication failed",toastProps:{duration:6e3}}):t(ae,{message:"Error fetching template data",toastProps:{duration:4e3}}),v.errors){let C=(m=v.errors)==null?void 0:m.map(P=>P.message);t(ae,{message:C.join(`
126
- `),toastProps:{duration:4e3}})}}catch{t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(be,!1)}});var ku=require("jotai"),Ip=require("sonner");function Pu(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t.type==="action"&&"content"in t&&"href"in t?{type:"action",content:t.content,href:t.href,...t.align&&{align:t.align},...t.background_color&&{background_color:t.background_color},...t.color&&{color:t.color},...t.style&&{style:t.style},...t.border&&{border:t.border}}:t)}a(Pu,"cleanInboxElements");function Np(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(Np,"cleanPushElements");function qs(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(qs,"cleanSMSElements");function Ap(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:Pu(t.elements)}:t)}}a(Ap,"cleanTemplateContent");function Sp(e,t){if(!(e!=null&&e.elements))return"none";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"none";if("raw"in r&&r.raw&&("subject"in r.raw&&r.raw.subject||"title"in r.raw&&r.raw.title))return"raw";if("elements"in r&&r.elements){let o=r.elements.find(n=>n.type==="meta");if(o&&"title"in o&&o.title)return"meta"}return"none"}a(Sp,"getSubjectStorageFormat");function bo(e,t,r,o){let n=Sp(e,t);if(t==="push"){let i=o.find(d=>d.type==="meta"&&"title"in d),s=i&&"title"in i?i.title:r,l=o.filter(d=>d.type!=="meta"),c=Np(l);return{elements:[{type:"meta",title:s},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
127
- `}]};if(t==="inbox"){let i=y2(o),s=i||r,l=i?o.slice(1):o,c=l.filter(v=>v.type==="text"),u=l.filter(v=>v.type==="action"),d=c[0],f=d?{type:"text",content:"content"in d?d.content:`
125
+ `,variables:{tenantId:i,input:{notificationId:s,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),y=await p.json(),h=p.status,v=(u=y.data)==null?void 0:u.tenant;if(v?(t(Tt,y),t(Si,(d=v==null?void 0:v.notification)==null?void 0:d.publishedAt),t(Ii,(f=v==null?void 0:v.notification)==null?void 0:f.version)):h===401?t(ae,{message:"Authentication failed",toastProps:{duration:6e3}}):t(ae,{message:"Error fetching template data",toastProps:{duration:4e3}}),y.errors){let C=(m=y.errors)==null?void 0:m.map(P=>P.message);t(ae,{message:C.join(`
126
+ `),toastProps:{duration:4e3}})}}catch{t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(ge,!1)}});var xu=require("jotai"),vp=require("sonner");function Cu(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t.type==="action"&&"content"in t&&"href"in t?{type:"action",content:t.content,href:t.href,...t.align&&{align:t.align},...t.background_color&&{background_color:t.background_color},...t.color&&{color:t.color},...t.style&&{style:t.style},...t.border&&{border:t.border}}:t)}a(Cu,"cleanInboxElements");function hp(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(hp,"cleanPushElements");function Us(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(Us,"cleanSMSElements");function bp(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:Cu(t.elements)}:t)}}a(bp,"cleanTemplateContent");function yp(e,t){if(!(e!=null&&e.elements))return"none";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"none";if("raw"in r&&r.raw&&("subject"in r.raw&&r.raw.subject||"title"in r.raw&&r.raw.title))return"raw";if("elements"in r&&r.elements){let o=r.elements.find(n=>n.type==="meta");if(o&&"title"in o&&o.title)return"meta"}return"none"}a(yp,"getSubjectStorageFormat");function po(e,t,r,o){let n=yp(e,t);if(t==="push"){let i=o.find(d=>d.type==="meta"&&"title"in d),s=i&&"title"in i?i.title:r,l=o.filter(d=>d.type!=="meta"),c=hp(l);return{elements:[{type:"meta",title:s},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
127
+ `}]};if(t==="inbox"){let i=l2(o),s=i||r,l=i?o.slice(1):o,c=l.filter(y=>y.type==="text"),u=l.filter(y=>y.type==="action"),d=c[0],f=d?{type:"text",content:"content"in d?d.content:`
128
128
  `}:{type:"text",content:`
129
- `},m=Pu(u);return{elements:[{type:"meta",title:s},f,...m]}}if(n==="raw"){let i={};return t==="email"?i.subject=r:i.title=r,{elements:o,raw:i}}else return{elements:[{type:"meta",title:r},...o]}}a(bo,"createTitleUpdate");function y2(e){if(e.length===0)return null;let t=e[0];if(t.type==="text"&&"content"in t&&t.content){let r=t.content.trim();if(r&&r!==`
130
- `)return r}return null}a(y2,"extractTitleFromFirstElement");function Da(e,t){if(!e||e.type!=="channel")return"";if("raw"in e&&e.raw){if(t==="email"&&"subject"in e.raw&&e.raw.subject)return e.raw.subject;if("title"in e.raw&&e.raw.title)return e.raw.title}if("elements"in e&&e.elements){let r=e.elements.find(s=>s.type==="meta");if(r&&"title"in r&&typeof r.title=="string")return r.title;if(t==="email")return"";let o="",n="";for(let s of e.elements)if(s.type==="text"&&"content"in s&&s.content){let l=s.content.trim();l&&l!==`
131
- `&&("text_style"in s&&(s.text_style==="h1"||s.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}a(Da,"extractCurrentTitle");var Js=(0,ku.atom)(null,async(e,t,r)=>{var m;let o,n;r&&typeof r=="object"&&"content"in r?(o=r.routing,n=r.content):o=r;let i=e(sr),s=e(lr),l=e(Vt),c=e(go),u=n||e(se);if(!u)return;let d=Ap(u);if(!i){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ot,!0),t(ae,null);let f={content:d,routing:o};try{let v=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${s}`,"x-courier-client-key":`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
129
+ `},m=Cu(u);return{elements:[{type:"meta",title:s},f,...m]}}if(n==="raw"){let i={};return t==="email"?i.subject=r:i.title=r,{elements:o,raw:i}}else return{elements:[{type:"meta",title:r},...o]}}a(po,"createTitleUpdate");function l2(e){if(e.length===0)return null;let t=e[0];if(t.type==="text"&&"content"in t&&t.content){let r=t.content.trim();if(r&&r!==`
130
+ `)return r}return null}a(l2,"extractTitleFromFirstElement");function Ma(e,t){if(!e||e.type!=="channel")return"";if("raw"in e&&e.raw){if(t==="email"&&"subject"in e.raw&&e.raw.subject)return e.raw.subject;if("title"in e.raw&&e.raw.title)return e.raw.title}if("elements"in e&&e.elements){let r=e.elements.find(s=>s.type==="meta");if(r&&"title"in r&&typeof r.title=="string")return r.title;if(t==="email")return"";let o="",n="";for(let s of e.elements)if(s.type==="text"&&"content"in s&&s.content){let l=s.content.trim();l&&l!==`
131
+ `&&("text_style"in s&&(s.text_style==="h1"||s.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}a(Ma,"extractCurrentTitle");var zs=(0,xu.atom)(null,async(e,t,r)=>{var m;let o,n;r&&typeof r=="object"&&"content"in r?(o=r.routing,n=r.content):o=r;let i=e(ar),s=e(sr),l=e(Vt),c=e(uo),u=n||e(se);if(!u)return;let d=bp(u);if(!i){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ot,!0),t(ae,null);let f={content:d,routing:o};try{let y=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${s}`,"x-courier-client-key":`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
132
132
  mutation SaveNotification($input: SaveNotificationInput!) {
133
133
  tenant {
134
134
  notification {
@@ -141,8 +141,8 @@ if (typeof require !== "undefined") {
141
141
  }
142
142
  }
143
143
  }
144
- `,variables:{input:{tenantId:l,notificationId:c,name:c,data:f}}})})).json();if(v.data)t(Vi,v.data.tenant.notification.save.version);else if(v.errors){let h=(m=v.errors)==null?void 0:m.map(g=>g.message);t(ae,{message:h.join(`
145
- `),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving template",toastProps:{duration:4e3}});return v}catch(p){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),p}finally{t(Ot,!1)}}),Lp=(0,ku.atom)(null,async(e,t)=>{let r=e(sr),o=e(lr),n=e(Vt),i=e(go),s=e(Vi);if(!s){t(ae,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(cr,!0),t(ae,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
144
+ `,variables:{input:{tenantId:l,notificationId:c,name:c,data:f}}})})).json();if(y.data)t(Ii,y.data.tenant.notification.save.version);else if(y.errors){let h=(m=y.errors)==null?void 0:m.map(v=>v.message);t(ae,{message:h.join(`
145
+ `),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving template",toastProps:{duration:4e3}});return y}catch(p){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),p}finally{t(Ot,!1)}}),Cp=(0,xu.atom)(null,async(e,t)=>{let r=e(ar),o=e(sr),n=e(Vt),i=e(uo),s=e(Ii);if(!s){t(ae,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(lr,!0),t(ae,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
146
146
  mutation PublishNotification($input: PublishNotificationInput!) {
147
147
  tenant {
148
148
  notification {
@@ -154,7 +154,7 @@ if (typeof require !== "undefined") {
154
154
  }
155
155
  }
156
156
  }
157
- `,variables:{input:{tenantId:n,notificationId:i,version:s}}})}),c=await l.json();return l.status===200?(Ip.toast.success("Template published"),t(Fi,new Date().toISOString()),t(Vi,c.data.tenant.notification.publish.version)):t(ae,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(cr,!1)}});function Wi(){Bi();let e=(0,yo.useSetAtom)(Zs),t=(0,yo.useSetAtom)(wp),r=(0,yo.useSetAtom)(Js),o=(0,yo.useSetAtom)(Ep),[n,i]=(0,yo.useAtom)(be),[s,l]=(0,yo.useAtom)(Ot),[c,u]=(0,yo.useAtom)(cr),[d,f]=(0,yo.useAtom)(ae),[m,p]=(0,yo.useAtom)(Tt);return{getTemplate:e,saveTemplate:r,saveBrand:t,publishBrand:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:a(h=>{f(h===null?null:typeof h=="string"?Oo(h):h)},"setTemplateError"),templateData:m,setTemplateData:p,createCustomError:Oo,convertLegacyError:Ra}}a(Wi,"useBrandActions");var to=require("jotai");var Rp=require("react");function Ui(){let e=(0,to.useSetAtom)(Zs),t=(0,to.useSetAtom)(Js),r=(0,to.useSetAtom)(Lp),[o,n]=(0,to.useAtom)(be),[i,s]=(0,to.useAtom)(Ot),[l,c]=(0,to.useAtom)(cr),[u,d]=(0,to.useAtom)(ae),[f,m]=(0,to.useAtom)(Tt),[p,v]=(0,to.useAtom)(se),[h,g]=(0,to.useAtom)(Eu),C=(0,Rp.useCallback)(P=>{d(P===null?null:typeof P=="string"?Oo(P):P)},[d]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,isTemplateLoading:o,setIsTemplateLoading:n,isTemplateSaving:i,setIsTemplateSaving:s,isTemplatePublishing:l,setIsTemplatePublishing:c,templateError:u,setTemplateError:C,templateData:f,setTemplateData:m,templateEditorContent:p,setTemplateEditorContent:v,createCustomError:Oo,convertLegacyError:Ra,contentTransformer:h,setContentTransformer:g}}a(Ui,"useTemplateActions");var Mu=require("jotai"),Hp=require("react");var v2=["image/png","image/jpeg","image/gif","image/webp"],Dp=a(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!v2.includes(e.type))throw new Error(`Invalid file type: ${e.type}. Only PNG, JPEG, GIF, and WebP images are supported.`);let n=e.name.split(".").pop()||"",i=`image_${Date.now()}_${Math.random().toString(36).substring(2,10)}.${n}`,l=(await new Promise((f,m)=>{let p=new FileReader;p.onload=()=>{typeof p.result=="string"?f(p.result):m(new Error("Failed to read file as data URL"))},p.onerror=()=>m(p.error),p.readAsDataURL(e)})).split(",")[1];try{let m=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
157
+ `,variables:{input:{tenantId:n,notificationId:i,version:s}}})}),c=await l.json();return l.status===200?(vp.toast.success("Template published"),t(Si,new Date().toISOString()),t(Ii,c.data.tenant.notification.publish.version)):t(ae,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(lr,!1)}});function Ri(){Ni();let e=(0,fo.useSetAtom)(Ws),t=(0,fo.useSetAtom)(dp),r=(0,fo.useSetAtom)(zs),o=(0,fo.useSetAtom)(mp),[n,i]=(0,fo.useAtom)(ge),[s,l]=(0,fo.useAtom)(Ot),[c,u]=(0,fo.useAtom)(lr),[d,f]=(0,fo.useAtom)(ae),[m,p]=(0,fo.useAtom)(Tt);return{getTemplate:e,saveTemplate:r,saveBrand:t,publishBrand:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:a(h=>{f(h===null?null:typeof h=="string"?Fo(h):h)},"setTemplateError"),templateData:m,setTemplateData:p,createCustomError:Fo,convertLegacyError:ka}}a(Ri,"useBrandActions");var Qr=require("jotai");var xp=require("react");function Di(){let e=(0,Qr.useSetAtom)(Ws),t=(0,Qr.useSetAtom)(zs),r=(0,Qr.useSetAtom)(Cp),[o,n]=(0,Qr.useAtom)(ge),[i,s]=(0,Qr.useAtom)(Ot),[l,c]=(0,Qr.useAtom)(lr),[u,d]=(0,Qr.useAtom)(ae),[f,m]=(0,Qr.useAtom)(Tt),[p,y]=(0,Qr.useAtom)(se),[h,v]=(0,Qr.useAtom)(vu),C=(0,xp.useCallback)(P=>{d(P===null?null:typeof P=="string"?Fo(P):P)},[d]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,isTemplateLoading:o,setIsTemplateLoading:n,isTemplateSaving:i,setIsTemplateSaving:s,isTemplatePublishing:l,setIsTemplatePublishing:c,templateError:u,setTemplateError:C,templateData:f,setTemplateData:m,templateEditorContent:p,setTemplateEditorContent:y,createCustomError:Fo,convertLegacyError:ka,contentTransformer:h,setContentTransformer:v}}a(Di,"useTemplateActions");var Tu=require("jotai"),wp=require("react");var c2=["image/png","image/jpeg","image/gif","image/webp"],Tp=a(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!c2.includes(e.type))throw new Error(`Invalid file type: ${e.type}. Only PNG, JPEG, GIF, and WebP images are supported.`);let n=e.name.split(".").pop()||"",i=`image_${Date.now()}_${Math.random().toString(36).substring(2,10)}.${n}`,l=(await new Promise((f,m)=>{let p=new FileReader;p.onload=()=>{typeof p.result=="string"?f(p.result):m(new Error("Failed to read file as data URL"))},p.onerror=()=>m(p.error),p.readAsDataURL(e)})).split(",")[1];try{let m=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
158
158
  mutation UploadImage($input: UploadImageInput!) {
159
159
  tenant {
160
160
  notification {
@@ -164,59 +164,59 @@ if (typeof require !== "undefined") {
164
164
  }
165
165
  }
166
166
  }
167
- `,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(m.errors)throw new Error(m.errors.map(v=>v.message).join(`
168
- `));let p=m.data;return(d=(u=(c=p==null?void 0:p.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:d.url}catch(f){throw console.error("Error uploading image:",f),f}},"uploadImage");function zi(){let[e]=(0,Mu.useAtom)(sr),[t]=(0,Mu.useAtom)(lr),r=Cp();return{uploadImage:(0,Hp.useCallback)(async n=>{if(typeof r=="function"){let i,s;try{i=await r(n),i===void 0&&(i=await r(n.file))}catch(u){s=u;try{i=await r(n.file)}catch{throw s}}let l="",c;if(typeof i=="string")l=i;else if(i){c=i==null?void 0:i.message;let u=i.url;typeof u=="string"?l=u:u&&typeof u=="object"&&(c=c||(u==null?void 0:u.message))}if(c)throw new Error(c);if(!l)throw s||new Error("Error uploading image");return{url:l}}else{if(!e||!t)throw new Error("Upload failed: Missing configuration for image upload");let i=n.file instanceof File?n.file:new File([n.file],"upload",{type:n.file.type}),s=await Dp(i,{apiUrl:e,token:t});if(!s)throw new Error("Upload failed: No URL returned from server");return{url:s}}},[e,t,r])}}a(zi,"useImageUpload");var Wp=require("clsx"),Up=require("tailwind-merge");var Wr=require("uuid");function ur(e){let t=e.trim();if(!t||t.startsWith(".")||t.endsWith(".")||t.includes("..")||t.includes(" "))return!1;let r=t.split("."),o=/^[a-zA-Z_][a-zA-Z0-9_]*$/;for(let n of r)if(!n||!o.test(n))return!1;return!0}a(ur,"isValidVariableName");function Bp(e){let t=[],r=e.replace(/\n$/,"").split(`
169
- `);for(let o=0;o<r.length;o++)C2(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}a(Bp,"parseMDContent");function C2(e,t){x2(e,t)}a(C2,"parseTextLine");function Fp(e,t){t.length!==0&&e.forEach(r=>{r.marks=r.marks||[],t.forEach(o=>{var n,i;(n=r.marks)!=null&&n.some(s=>s.type===o.type)||(i=r.marks)==null||i.push({type:o.type,...o.href&&{attrs:{href:o.href}}})}),r.marks.length===0&&delete r.marks})}a(Fp,"applyMarks");function x2(e,t){if(!e)return;let r=[],o=/\[([^\]]+)\]\(([^)]+)\)/g,n,i=0;for(;(n=o.exec(e))!==null;)n.index>i&&r.push({type:"text",text:e.substring(i,n.index),start:i,end:n.index}),r.push({type:"link",text:n[1],start:n.index,end:n.index+n[1].length,attrs:{href:n[2]}}),i=n.index+n[0].length;i<e.length&&r.push({type:"text",text:e.substring(i),start:i,end:e.length});let s=[];for(let u of r){if(u.type==="link"){s.push(u);continue}let d=0,f=/(\*\*|\*|__|_|~|\+|\{\{[^}]+\}\}|\{\}[^{}]+\{\})/g,m=u.text,p;for(;(p=f.exec(m))!==null;){let v=p.index,h=p[0],g=v+h.length;if(v>d&&s.push({type:"text",text:m.substring(d,v),start:u.start+d,end:u.start+v}),h.startsWith("{{")||h.startsWith("{}")){let C=h.startsWith("{{")?h.slice(2,-2).trim():h.substring(2,h.length-2).trim();ur(C)?s.push({type:"variable",text:h,start:u.start+v,end:u.start+g,attrs:{id:C}}):s.push({type:"text",text:h,start:u.start+v,end:u.start+g})}else s.push({type:"marker",text:h,start:u.start+v,end:u.start+g});d=g}d<m.length&&s.push({type:"text",text:m.substring(d),start:u.start+d,end:u.start+m.length})}s.sort((u,d)=>u.start-d.start);let l=[],c=[];for(let u of s)if(u.type==="text"){let d=[];Nu(u.text,[],d),Fp(d,l),c.push(...d)}else if(u.type==="variable"){let d={type:"variable",attrs:u.attrs};Fp([d],l),c.push(d)}else if(u.type==="link"){let d=[];Nu(u.text,[],d),d.forEach(f=>{var m;f.marks=f.marks||[],f.marks.push({type:"link",attrs:{href:(m=u.attrs)==null?void 0:m.href}})}),c.push(...d)}else if(u.type==="marker"){let d=u.text;if(["**","*","__","_","~","+"].includes(d)){let f=d==="**"||d==="__"?"bold":d==="*"||d==="_"?"italic":d==="~"?"strike":"underline",m=l.findLastIndex(p=>p.text===d);m!==-1?l.splice(m,1):l.push({type:f,text:d,start:u.start})}}t.push(...c)}a(x2,"processMarkdownFormatting");function Nu(e,t,r){if(!e)return;let o=/\{\{([^}]+)\}\}/g,n,i=0;for(o.lastIndex=0;(n=o.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;if(n.index>i){let c=e.substring(i,n.index);c&&r.push({type:"text",text:c,...t.length>0&&{marks:t}})}let s=n[1].trim(),l=t.some(c=>c.type==="link");s&&ur(s)?r.push({type:"variable",attrs:{id:s,...l&&{inUrlContext:!0}},...t.length>0&&{marks:t}}):r.push({type:"text",text:n[0],...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);s&&r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(Nu,"parseTextWithVariables");function Qe(e,t){var d,f,m,p,v,h,g,C,P;let r={type:"doc",content:[]};if(!e||!e.elements||e.elements.length===0)return r;let o,n=t==null?void 0:t.channel,i;for(let y of e.elements)if(y.type==="channel"){let b=y;if(n){if(b.channel===n){i=b;break}}else{i=b;break}}if(!i||i.type!=="channel")return r;let s=i;if(s.elements&&s.elements.length>0?(o=s.elements,s.channel==="push"&&(o=o.map(y=>y.type==="meta"&&"title"in y?{type:"text",content:y.title||`
170
- `,text_style:"h2"}:y))):o=[{type:"text",content:`
171
- `}],!o||o.length===0)return r;let l=a(y=>{var b,A,x;if(y.type==="meta")return[];switch(y.type){case"text":if("content"in y){let I=y.text_style==="h1"?1:y.text_style==="h2"?2:null,T={};if(y.padding){let[E,N]=y.padding.replace(/px/g,"").split(" "),M=parseInt(E),S=parseInt(N);!isNaN(M)&&!isNaN(S)&&(T={paddingVertical:M,paddingHorizontal:S})}let k={};(b=y.border)!=null&&b.enabled&&(k={...y.border.color&&{borderColor:y.border.color},...y.border.size&&{borderWidth:parseInt(y.border.size)},...y.border.radius&&{borderRadius:y.border.radius}});let w=y.content.trim()?Bp(y.content):[];return[{type:I?"heading":"paragraph",attrs:{textAlign:y.align||"left",level:I,id:`node-${(0,Wr.v4)()}`,...T,...y.color&&{textColor:y.color},...y.background_color&&{backgroundColor:y.background_color},...k,...y.locales&&{locales:y.locales}},content:w}]}return[];case"action":{let T=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"#000000",borderWidth:1,borderRadius:4}:{},k=y.content||"Button",w=[];return Nu(k,[],w),w.length===0&&w.push({type:"text",text:k||"Button"}),[{type:"button",content:w,attrs:{label:k,link:y.href,alignment:y.align==="full"?"center":y.align||"center",size:y.align==="full"?"full":"default",style:y.style,id:`node-${(0,Wr.v4)()}`,...T,...y.background_color&&{backgroundColor:y.background_color},...y.color&&{textColor:y.color},...y.padding&&{padding:parseInt(y.padding)},...((A=y.border)==null?void 0:A.enabled)&&{...y.border.color&&{borderColor:y.border.color},...y.border.size&&{borderWidth:parseInt(y.border.size)},...y.border.radius&&{borderRadius:y.border.radius}},...y.locales&&{locales:y.locales}}}]}case"quote":{let I="paragraph",T;y.text_style==="h1"?(I="heading",T=1):y.text_style==="h2"?(I="heading",T=2):y.text_style==="subtext"&&(I="heading",T=3);let k={textAlign:y.align||"left",id:`node-${(0,Wr.v4)()}`};return T!==void 0&&(k.level=T),[{type:"blockquote",attrs:{textAlign:y.align||"left",id:`node-${(0,Wr.v4)()}`,...y.border_color&&{borderColor:y.border_color},...y.border_left_width!==void 0&&{borderLeftWidth:y.border_left_width},...y.padding_horizontal!==void 0&&{paddingHorizontal:y.padding_horizontal},...y.padding_vertical!==void 0&&{paddingVertical:y.padding_vertical},...y.background_color&&{backgroundColor:y.background_color},...y.locales&&{locales:y.locales}},content:[{type:I,attrs:k,content:Bp(y.content)}]}]}case"image":return[{type:"imageBlock",attrs:{sourcePath:y.src,id:`node-${(0,Wr.v4)()}`,...y.href&&{link:y.href},...y.align&&{alignment:y.align},...y.alt_text&&{alt:y.alt_text},...y.width&&{width:parseInt(y.width.replace(/%|px/,""))},...((x=y.border)==null?void 0:x.enabled)&&{...y.border.color&&{borderColor:y.border.color},...y.border.size&&{borderWidth:parseInt(y.border.size)},...y.border.radius&&{borderRadius:parseInt(y.border.radius)}},...y.locales&&{locales:y.locales}}}];case"divider":return[{type:"divider",attrs:{id:`node-${(0,Wr.v4)()}`,...y.color&&{color:y.color},...y.width&&{size:parseInt(y.width)},...y.padding&&{padding:parseInt(y.padding)},variant:y.color==="transparent"?"spacer":"divider"}}];case"html":return[{type:"customCode",attrs:{id:`node-${(0,Wr.v4)()}`,code:y.content||"<!-- Add your HTML code here -->",...y.locales&&{locales:y.locales}}}];case"group":{let I=y.elements?y.elements.length:2,T=0,k=0;if(y.padding){let L=y.padding.split(" ");T=parseInt(L[0],10)||0,k=parseInt(L[1]||L[0],10)||0}let w=0,E=0,N="#000000";y.border&&(y.border.size&&(w=parseInt(y.border.size,10)||0),y.border.radius!==void 0&&(E=y.border.radius),y.border.color&&(N=y.border.color));let M=y.background_color||"transparent",S=`node-${(0,Wr.v4)()}`,D=y.elements?y.elements.map((L,B)=>{var W;if(L.type==="text"&&"content"in L&&((W=L.content)==null?void 0:W.trim())==="Drag and drop content blocks"&&L.align==="left")return{type:"columnCell",attrs:{index:B,columnId:S,isEditorMode:!1},content:[]};let O;L.type==="group"&&L.elements?O=L.elements.flatMap(l):O=l(L);let j=O.length>0?O:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Wr.v4)()}`},content:[]}];return{type:"columnCell",attrs:{index:B,columnId:S,isEditorMode:O.length>0},content:j}}):[{type:"columnCell",attrs:{index:0,columnId:S,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Wr.v4)()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:S,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Wr.v4)()}`},content:[]}]}];return[{type:"column",attrs:{id:S,columnsCount:Math.min(Math.max(I,1),4),paddingVertical:T,paddingHorizontal:k,backgroundColor:M,borderWidth:w,borderRadius:E,borderColor:N,...y.locales&&{locales:y.locales}},content:[{type:"columnRow",content:D}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let y=0;y<u.length;y++){let b=u[y],A=u[y+1];if(b.type==="button"&&(A==null?void 0:A.type)==="button"&&n==="inbox"){let x={type:"buttonRow",attrs:{id:`node-${(0,Wr.v4)()}`,button1Label:((d=b.attrs)==null?void 0:d.label)||"Button 1",button1Link:((f=b.attrs)==null?void 0:f.link)||"",button1BackgroundColor:((m=b.attrs)==null?void 0:m.backgroundColor)||"#000000",button1TextColor:((p=b.attrs)==null?void 0:p.textColor)||"#ffffff",button2Label:((v=A.attrs)==null?void 0:v.label)||"Button 2",button2Link:((h=A.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((g=A.attrs)==null?void 0:g.backgroundColor)||"#ffffff",button2TextColor:((C=A.attrs)==null?void 0:C.textColor)||"#000000",padding:((P=b.attrs)==null?void 0:P.padding)||6}};c.push(x),y++}else c.push(b)}return{type:"doc",content:c}}a(Qe,"convertElementalToTiptap");function Vp(e,t){t.length!==0&&e.forEach(r=>{r.marks=r.marks||[],t.forEach(o=>{var n,i;(n=r.marks)!=null&&n.some(s=>s.type===o.type)||(i=r.marks)==null||i.push({type:o.type,...o.href&&{attrs:{href:o.href}}})}),r.marks.length===0&&delete r.marks})}a(Vp,"applyMarks");function Op(e,t,r){if(!e)return;let o=/{{([^}]+)}}/g,n,i=0;for(;(n=o.exec(e))!==null;){if(n.index>i){let l=e.substring(i,n.index);r.push({type:"text",text:l,...t.length>0&&{marks:t}})}let s=n[1].trim();ur(s)?r.push({type:"variable",attrs:{id:s},...t.length>0&&{marks:t}}):r.push({type:"text",text:n[0],...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(Op,"parseTextWithVariables");function Au(e){if(!e)return[];let t=[],r=/\[([^\]]+)\]\(([^)]+)\)/g,o,n=0;for(;(o=r.exec(e))!==null;)o.index>n&&t.push({type:"text",text:e.substring(n,o.index),start:n,end:o.index}),t.push({type:"link",text:o[1],start:o.index,end:o.index+o[1].length,attrs:{href:o[2]}}),n=o.index+o[0].length;n<e.length&&t.push({type:"text",text:e.substring(n),start:n,end:e.length});let i=[];for(let c of t){if(c.type==="link"){i.push(c);continue}let u=0,d=/(\*\*|\*|__|_|~|\+|{{[^}]+}})/g,f=c.text,m;for(;(m=d.exec(f))!==null;){let p=m.index,v=m[0],h=p+v.length;if(p>u&&i.push({type:"text",text:f.substring(u,p),start:c.start+u,end:c.start+p}),v.startsWith("{{")){let g=v.slice(2,-2).trim();ur(g)?i.push({type:"variable",text:v,start:c.start+p,end:c.start+h,attrs:{id:g}}):i.push({type:"text",text:v,start:c.start+p,end:c.start+h})}else i.push({type:"marker",text:v,start:c.start+p,end:c.start+h});u=h}u<f.length&&i.push({type:"text",text:f.substring(u),start:c.start+u,end:c.start+f.length})}i.sort((c,u)=>c.start-u.start);let s=[],l=[];for(let c of i)if(c.type==="text"){let u=[];Op(c.text,[],u),Vp(u,s),l.push(...u)}else if(c.type==="variable"){let u={type:"variable",attrs:c.attrs};Vp([u],s),l.push(u)}else if(c.type==="link"){let u=[];Op(c.text,[],u),u.forEach(d=>{var f;d.marks=d.marks||[],d.marks.push({type:"link",attrs:{href:(f=c.attrs)==null?void 0:f.href}})}),l.push(...u)}else if(c.type==="marker"){let u=c.text;if(["**","*","__","_","~","+"].includes(u)){let d=u==="**"||u==="__"?"bold":u==="*"||u==="_"?"italic":u==="~"?"strike":"underline",f=s.findLastIndex(m=>m.text===u);f!==-1?s.splice(f,1):s.push({type:d,text:u,start:c.start})}}return l}a(Au,"processMarkdownFormatting");function T2(e){let t=[],r=e.split(/\n/);for(let o of r){if(!o.trim())continue;let n=o.match(/^(#{1,6})\s+(.*)$/);if(n){t.push({type:"heading",attrs:{level:n[1].length,textAlign:"left"},content:Au(n[2])});continue}if(o.startsWith(">")){let s=o.slice(1).trim();t.push({type:"blockquote",attrs:{textAlign:"left"},content:[{type:"paragraph",attrs:{textAlign:"left"},content:Au(s)}]});continue}if(o.match(/^-{3,}$/)){t.push({type:"divider"});continue}let i=o.match(/^!\[(.*?)\]\((.*?)(?:\s+"(.*?)")?\)$/);if(i){t.push({type:"imageBlock",attrs:{sourcePath:i[2],alt:i[1]||"",...i[3]&&{title:i[3]}}});continue}t.push({type:"paragraph",attrs:{textAlign:"left"},content:Au(o)})}return t}a(T2,"parseBlockContent");function Su(e){return{type:"doc",content:T2(e)}}a(Su,"convertMarkdownToTiptap");var w2=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Gs=a(e=>{var o,n,i,s;if(e.type==="variable")return`{{${(o=e.attrs)==null?void 0:o.id}}}`;let t=e.text||"";if((n=e.marks)!=null&&n.length){let l=e.marks.map(w2).filter(Boolean);t=l.join("")+t+l.reverse().join("")}let r=(i=e.marks)==null?void 0:i.find(l=>l.type==="link");return r&&(t=`[${t}](${(s=r.attrs)==null?void 0:s.href})`),t},"convertTextToMarkdown");function Te(e){let t=a(r=>{var o,n,i,s,l,c,u,d,f,m,p,v,h,g,C,P,y,b,A,x,I,T,k,w,E,N,M,S,D,L,B,V,O,j,W,_,Q,re,ee,F,G,ce,ge,fe,Ne,mt,ue,Re,ke,nt,it,Yt,Xt,at,pt,yr,Qt,ie,vr,Xr,Qr,Fo,$n,jn,Zn,qn,Jn,H,Y,oe,Pe,ve,st,Nt,Qo,Ia,Vo,Li,Gn,en,zs,Ri,Kn,cp,up,dp,mp,pp,fp;switch(r.type){case"paragraph":{let me="",he=r.content||[];for(let Le=0;Le<he.length;Le++)he[Le].type==="hardBreak"?me+=`
172
- `:me+=Gs(he[Le]);me+=`
173
- `;let Ce={};if((o=r.attrs)!=null&&o.borderWidth||(n=r.attrs)!=null&&n.borderColor||(i=r.attrs)!=null&&i.borderRadius){let Le={};(s=r.attrs)!=null&&s.borderColor&&(Le.color=r.attrs.borderColor),Le.enabled=!0,(l=r.attrs)!=null&&l.borderWidth&&(Le.size=`${r.attrs.borderWidth}px`),(c=r.attrs)!=null&&c.borderRadius&&(Le.radius=r.attrs.borderRadius),Ce.border=Le}((u=r.attrs)==null?void 0:u.paddingVertical)!==void 0&&((d=r.attrs)==null?void 0:d.paddingHorizontal)!==void 0&&(Ce.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(f=r.attrs)!=null&&f.textColor&&(Ce.color=r.attrs.textColor),(m=r.attrs)!=null&&m.backgroundColor&&(Ce.background_color=r.attrs.backgroundColor),Ce.type="text",Ce.align=((p=r.attrs)==null?void 0:p.textAlign)||"left",Ce.content=me;let Ft=Ce;return(v=r.attrs)!=null&&v.locales&&(Ft.locales=r.attrs.locales),[Ft]}case"heading":{let me="",he=r.content||[];for(let Le=0;Le<he.length;Le++)he[Le].type==="hardBreak"?me+=`
174
- `:me+=Gs(he[Le]);me+=`
175
- `;let Ce={};if((h=r.attrs)!=null&&h.borderWidth||(g=r.attrs)!=null&&g.borderColor||(C=r.attrs)!=null&&C.borderRadius){let Le={};(P=r.attrs)!=null&&P.borderColor&&(Le.color=r.attrs.borderColor),Le.enabled=!0,(y=r.attrs)!=null&&y.borderWidth&&(Le.size=`${r.attrs.borderWidth}px`),(b=r.attrs)!=null&&b.borderRadius&&(Le.radius=r.attrs.borderRadius),Ce.border=Le}Ce.text_style=((A=r.attrs)==null?void 0:A.level)===1?"h1":"h2",((x=r.attrs)==null?void 0:x.paddingVertical)!==void 0&&((I=r.attrs)==null?void 0:I.paddingHorizontal)!==void 0&&(Ce.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(T=r.attrs)!=null&&T.textColor&&(Ce.color=r.attrs.textColor),(k=r.attrs)!=null&&k.backgroundColor&&(Ce.background_color=r.attrs.backgroundColor),Ce.type="text",Ce.align=((w=r.attrs)==null?void 0:w.textAlign)||"left",Ce.content=me;let Ft=Ce;return(E=r.attrs)!=null&&E.locales&&(Ft.locales=r.attrs.locales),[Ft]}case"blockquote":{let me="",he;if(r.content)for(let Ft of r.content){if(!he&&Ft.type==="heading"){let Le=(N=Ft.attrs)==null?void 0:N.level;Le===1?he="h1":Le===2?he="h2":he="subtext"}if(Ft.content)for(let Le of Ft.content)Le.type==="hardBreak"?me+=`
176
- `:me+=Gs(Le);me+=`
177
- `}me=me.trim();let Ce={type:"quote",content:me};return((M=r.attrs)==null?void 0:M.textAlign)!=="left"&&(Ce.align=(S=r.attrs)==null?void 0:S.textAlign),(D=r.attrs)!=null&&D.borderColor&&(Ce.border_color=r.attrs.borderColor),((L=r.attrs)==null?void 0:L.borderLeftWidth)!==void 0&&(Ce.border_left_width=r.attrs.borderLeftWidth),((B=r.attrs)==null?void 0:B.paddingHorizontal)!==void 0&&(Ce.padding_horizontal=r.attrs.paddingHorizontal),((V=r.attrs)==null?void 0:V.paddingVertical)!==void 0&&(Ce.padding_vertical=r.attrs.paddingVertical),(O=r.attrs)!=null&&O.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(Ce.background_color=r.attrs.backgroundColor),he&&(Ce.text_style=he),(j=r.attrs)!=null&&j.locales&&(Ce.locales=r.attrs.locales),[Ce]}case"imageBlock":{let me={};if((W=r.attrs)!=null&&W.width&&(typeof r.attrs.width=="number"?me.width=`${r.attrs.width}%`:me.width=`${r.attrs.width}%`),(_=r.attrs)!=null&&_.borderWidth||(Q=r.attrs)!=null&&Q.borderColor||(re=r.attrs)!=null&&re.borderRadius){let Ce={};(ee=r.attrs)!=null&&ee.borderColor&&(Ce.color=r.attrs.borderColor),Ce.enabled=!0,(F=r.attrs)!=null&&F.borderWidth&&(Ce.size=`${r.attrs.borderWidth}px`),(G=r.attrs)!=null&&G.borderRadius&&(Ce.radius=`${r.attrs.borderRadius}px`),me.border=Ce}me.type="image",me.src=((ce=r.attrs)==null?void 0:ce.sourcePath)||"",(ge=r.attrs)!=null&&ge.alignment&&(me.align=r.attrs.alignment),(fe=r.attrs)!=null&&fe.link&&(me.href=r.attrs.link),(Ne=r.attrs)!=null&&Ne.alt&&(me.alt_text=r.attrs.alt);let he=me;return(mt=r.attrs)!=null&&mt.locales&&(he.locales=r.attrs.locales),[he]}case"divider":{let me={type:"divider"};return(ue=r.attrs)!=null&&ue.color&&(me.color=r.attrs.color),(Re=r.attrs)!=null&&Re.size&&(me.width=`${r.attrs.size}px`),(ke=r.attrs)!=null&&ke.padding&&(me.padding=`${r.attrs.padding}px`),[me]}case"button":{let me=(it=(nt=r.attrs)==null?void 0:nt.label)!=null?it:"";r.content&&r.content.length>0&&(me=r.content.map(Gs).join(""));let he={type:"action",content:me,href:(Xt=(Yt=r.attrs)==null?void 0:Yt.link)!=null?Xt:"#"};return(at=r.attrs)!=null&&at.style&&(he.style=r.attrs.style),he.align=((pt=r.attrs)==null?void 0:pt.size)==="full"?"full":((yr=r.attrs)==null?void 0:yr.alignment)||"center",(Qt=r.attrs)!=null&&Qt.backgroundColor&&(he.background_color=r.attrs.backgroundColor),(ie=r.attrs)!=null&&ie.textColor&&(he.color=r.attrs.textColor),(vr=r.attrs)!=null&&vr.padding&&(he.padding=`${r.attrs.padding}px`),((Xr=r.attrs)!=null&&Xr.borderWidth||(Qr=r.attrs)!=null&&Qr.borderColor||(Fo=r.attrs)!=null&&Fo.borderRadius)&&(he.border={enabled:!0},($n=r.attrs)!=null&&$n.borderColor&&(he.border.color=r.attrs.borderColor),(jn=r.attrs)!=null&&jn.borderWidth&&(he.border.size=`${r.attrs.borderWidth}px`),(Zn=r.attrs)!=null&&Zn.borderRadius&&(he.border.radius=r.attrs.borderRadius)),(qn=r.attrs)!=null&&qn.locales&&(he.locales=r.attrs.locales),[he]}case"buttonRow":{let me={type:"action",content:(H=(Jn=r.attrs)==null?void 0:Jn.button1Label)!=null?H:"Button 1",href:(oe=(Y=r.attrs)==null?void 0:Y.button1Link)!=null?oe:"#",align:"left"};(Pe=r.attrs)!=null&&Pe.button1BackgroundColor&&(me.background_color=r.attrs.button1BackgroundColor),(ve=r.attrs)!=null&&ve.button1TextColor&&(me.color=r.attrs.button1TextColor);let he={type:"action",content:(Nt=(st=r.attrs)==null?void 0:st.button2Label)!=null?Nt:"Button 2",href:(Ia=(Qo=r.attrs)==null?void 0:Qo.button2Link)!=null?Ia:"#",align:"left"};return(Vo=r.attrs)!=null&&Vo.button2BackgroundColor&&(he.background_color=r.attrs.button2BackgroundColor),(Li=r.attrs)!=null&&Li.button2TextColor&&(he.color=r.attrs.button2TextColor),[me,he]}case"customCode":{let me={type:"html",content:((Gn=r.attrs)==null?void 0:Gn.code)||"<!-- Add your HTML code here -->"};return(en=r.attrs)!=null&&en.locales&&(me.locales=r.attrs.locales),[me]}case"column":{let me=((zs=r.attrs)==null?void 0:zs.columnsCount)||2,he=[],Ce=(Ri=r.content)==null?void 0:Ri.find(ar=>ar.type==="columnRow");if(Ce&&Ce.content){for(let ar of Ce.content)if(ar.type==="columnCell")if(ar.content&&ar.content.length>0){let _s=ar.content.flatMap(t);_s.length===0?he.push({type:"text",content:`Drag and drop content blocks
178
- `,align:"left"}):_s.length===1?he.push(_s[0]):he.push({type:"group",elements:_s})}else he.push({type:"text",content:`Drag and drop content blocks
179
- `,align:"left"})}else for(let ar=0;ar<me;ar++)he.push({type:"text",content:`Drag and drop content blocks
180
- `,align:"left"});let Ft={type:"group"};if((Kn=r.attrs)!=null&&Kn.borderWidth&&r.attrs.borderWidth>0){let ar={};(cp=r.attrs)!=null&&cp.borderColor&&(ar.color=r.attrs.borderColor),ar.enabled=!0,ar.size=`${r.attrs.borderWidth}px`,(up=r.attrs)!=null&&up.borderRadius&&(ar.radius=r.attrs.borderRadius),Ft.border=ar}let Le=((dp=r.attrs)==null?void 0:dp.paddingVertical)||0,gp=((mp=r.attrs)==null?void 0:mp.paddingHorizontal)||0;return(Le>0||gp>0)&&(Ft.padding=`${Le}px ${gp}px`),(pp=r.attrs)!=null&&pp.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(Ft.background_color=r.attrs.backgroundColor),Ft.elements=he,(fp=r.attrs)!=null&&fp.locales&&(Ft.locales=r.attrs.locales),[Ft]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}a(Te,"convertTiptapToElemental");function Iu(e){let t="",r="";for(let o of e)if(!("visible"in o&&o.visible===!1)){if(o.type==="meta"&&"title"in o&&o.title)return o.title;if(o.type==="channel"&&"raw"in o&&o.raw){if("subject"in o.raw&&o.raw.subject)return o.raw.subject;if("title"in o.raw&&o.raw.title)return o.raw.title}if(o.type==="text"&&"content"in o&&o.content){let n=o.content.trim();n&&n!==`
181
- `&&("text_style"in o&&(o.text_style==="h1"||o.text_style==="h2")?r||(r=n):t||(t=n))}if(o.type==="channel"&&"elements"in o&&o.elements){let n=Iu(o.elements);if(n)return n}}return r||t||""}a(Iu,"getTitle");function Lu(e,t){if(!e||!e.elements)return"";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"";if("raw"in r&&r.raw){if("subject"in r.raw&&r.raw.subject)return r.raw.subject;if("title"in r.raw&&r.raw.title)return r.raw.title}if("elements"in r&&r.elements){if(t==="email"){let o=r.elements.find(n=>n.type==="meta");return o&&"title"in o&&o.title?o.title:""}return Iu(r.elements)}return""}a(Lu,"getTitleForChannel");function At(e,t){var s;let r=e||{version:"2022-01-01",elements:[]},o={...r,elements:[]},n;typeof t.channel=="string"?n=t.channel:t.channel&&typeof t.channel.channel=="string"?n=t.channel.channel:t.channel;let i=!1;if(r.elements&&Array.isArray(r.elements)&&r.elements.forEach(l=>{var c;if(l.type!=="meta")if(l.type==="channel"){let u=l,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let f={};if(t.channel&&typeof t.channel=="object")for(let p in t.channel)p!=="type"&&p!=="elements"&&p!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,p)&&(f[p]=t.channel[p]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([p])=>!["type","channel","elements"].includes(p))),...f};if(t.elements!==void 0){let p=[],v=t.elements.find(g=>g.type==="meta");if(v)p.push(v);else{let g=(c=u.elements)==null?void 0:c.find(C=>C.type==="meta");g&&p.push(g)}let h=t.elements.filter(g=>g.type!=="meta");p.push(...h),m.elements=p}o.elements.push(m),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((s=r.elements)!=null&&s.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};if(t.channel&&typeof t.channel=="object")for(let d in t.channel)d!=="type"&&d!=="elements"&&d!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,d)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],f=t.elements.find(p=>p.type==="meta");f&&d.push(f);let m=t.elements.filter(p=>p.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}a(At,"updateElemental");function R(...e){return(0,Up.twMerge)((0,Wp.clsx)(e))}a(R,"cn");var zp=require("@radix-ui/react-slot"),_p=require("class-variance-authority"),$p=require("react"),jp=require("react/jsx-runtime"),Ks=(0,_p.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6] dark:courier-text-foreground dark:courier-bg-white dark:courier-border-white",secondary:"courier-text-foreground courier-bg-[#F5F5F5]",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-800 active:courier-bg-neutral-900 dark:hover:courier-bg-neutral-200 dark:active:courier-bg-neutral-300"},{variant:"primary",active:!0,class:"courier-bg-neutral-900 dark:courier-bg-neutral-300"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-900 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-white/20 dark:courier-text-neutral-200"}]}),Oe=(0,$p.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...s},l)=>(0,jp.jsx)(i?zp.Slot:"button",{ref:l,disabled:r,className:R(Ks({variant:o,size:t,disabled:r,active:e}),n),...s}));Oe.displayName="Button";var Zp=require("react"),qp=require("react/jsx-runtime"),ye=(0,Zp.forwardRef)((e,t)=>(0,qp.jsx)("hr",{...e,ref:t,className:R("courier-my-1 courier-border-border dark:courier-border-neutral-800 courier-w-full",e.className)}));ye.displayName="Divider";var tn=Ae(require("react"),1),we=Ae(require("@radix-ui/react-dropdown-menu"),1),_i=require("lucide-react");var Et=require("react/jsx-runtime"),Ys=we.Root,Xs=we.Trigger;var E2=tn.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,Et.jsxs)(we.SubTrigger,{ref:n,className:R("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,Et.jsx)(_i.ChevronRight,{className:"courier-ml-auto"})]}));E2.displayName=we.SubTrigger.displayName;var P2=tn.forwardRef(({className:e,...t},r)=>(0,Et.jsx)(we.SubContent,{ref:r,className:R("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));P2.displayName=we.SubContent.displayName;var Ha=tn.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,Et.jsx)(we.Portal,{...r,children:(0,Et.jsx)(we.Content,{ref:n,sideOffset:t,className:R("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));Ha.displayName=we.Content.displayName;var Ba=tn.forwardRef(({className:e,inset:t,...r},o)=>(0,Et.jsx)(we.Item,{ref:o,className:R("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));Ba.displayName=we.Item.displayName;var k2=tn.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,Et.jsxs)(we.CheckboxItem,{ref:n,className:R("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,Et.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,Et.jsx)(we.ItemIndicator,{children:(0,Et.jsx)(_i.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));k2.displayName=we.CheckboxItem.displayName;var M2=tn.forwardRef(({className:e,children:t,...r},o)=>(0,Et.jsxs)(we.RadioItem,{ref:o,className:R("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,Et.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,Et.jsx)(we.ItemIndicator,{children:(0,Et.jsx)(_i.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));M2.displayName=we.RadioItem.displayName;var N2=tn.forwardRef(({className:e,inset:t,...r},o)=>(0,Et.jsx)(we.Label,{ref:o,className:R("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));N2.displayName=we.Label.displayName;var A2=tn.forwardRef(({className:e,...t},r)=>(0,Et.jsx)(we.Separator,{ref:r,className:R("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));A2.displayName=we.Separator.displayName;var S2=a(({className:e,...t})=>(0,Et.jsx)("span",{className:R("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");S2.displayName="DropdownMenuShortcut";var Jp=require("react");var $i=require("react/jsx-runtime"),Ru=class Ru extends Jp.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,$i.jsx)(I2,{error:this.state.error}):this.props.children}};a(Ru,"ErrorBoundary");var Qs=Ru,I2=a(({error:e})=>(0,$i.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,$i.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,$i.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var Xp=require("@radix-ui/react-slot"),xr=Ae(require("react"),1),ji=require("react-hook-form");var Du=Ae(require("@radix-ui/react-label"),1),Gp=require("class-variance-authority"),Kp=Ae(require("react"),1),Yp=require("react/jsx-runtime"),L2=(0,Gp.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),Hu=Kp.forwardRef(({className:e,...t},r)=>(0,Yp.jsx)(Du.Root,{ref:r,className:R(L2(),e),...t}));Hu.displayName=Du.Root.displayName;var rn=require("react/jsx-runtime"),et=ji.FormProvider,Qp=xr.createContext({}),J=a(({...e})=>(0,rn.jsx)(Qp.Provider,{value:{name:e.name},children:(0,rn.jsx)(ji.Controller,{...e})}),"FormField"),el=a(()=>{let e=xr.useContext(Qp),t=xr.useContext(ef),{getFieldState:r,formState:o}=(0,ji.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),ef=xr.createContext({}),Z=xr.forwardRef(({className:e,...t},r)=>{let o=xr.useId();return(0,rn.jsx)(ef.Provider,{value:{id:o},children:(0,rn.jsx)("div",{ref:r,className:R("courier-space-y-2",e),...t})})});Z.displayName="FormItem";var Uo=xr.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=el();return(0,rn.jsx)(Hu,{ref:r,className:R(o&&"courier-text-destructive",e),htmlFor:n,...t})});Uo.displayName="FormLabel";var q=xr.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=el();return(0,rn.jsx)(Xp.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});q.displayName="FormControl";var R2=xr.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=el();return(0,rn.jsx)("p",{ref:r,id:o,className:R("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});R2.displayName="FormDescription";var K=xr.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=el(),s=n?String(n==null?void 0:n.message):t;return s?(0,rn.jsx)("p",{ref:o,id:i,className:R("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:s}):null});K.displayName="FormMessage";var qe=Ae(require("@radix-ui/react-alert-dialog"),1),ei=Ae(require("react"),1);var tf=require("react");var Ur=require("react/jsx-runtime"),rf=qe.Root,of=qe.Trigger,D2=qe.Portal,nf=ei.forwardRef(({className:e,...t},r)=>(0,Ur.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,Ur.jsx)(qe.Overlay,{asChild:!0,className:R("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));nf.displayName=qe.Overlay.displayName;var Bu=ei.forwardRef(({className:e,...t},r)=>{let o=(0,tf.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,Ur.jsxs)(D2,{container:typeof window!="undefined"?o():void 0,children:[(0,Ur.jsx)(nf,{}),(0,Ur.jsx)(qe.Content,{ref:r,className:R("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});Bu.displayName=qe.Content.displayName;var Fu=a(({className:e,...t})=>(0,Ur.jsx)("div",{className:R("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");Fu.displayName="AlertDialogHeader";var Vu=a(({className:e,...t})=>(0,Ur.jsx)("div",{className:R("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Vu.displayName="AlertDialogFooter";var H2=ei.forwardRef(({className:e,...t},r)=>(0,Ur.jsx)(qe.Title,{ref:r,className:R("courier-text-lg courier-font-semibold",e),...t}));H2.displayName=qe.Title.displayName;var B2=ei.forwardRef(({className:e,...t},r)=>(0,Ur.jsx)(qe.Description,{ref:r,className:R("courier-text-sm courier-text-muted-foreground",e),...t}));B2.displayName=qe.Description.displayName;var Ou=ei.forwardRef(({className:e,...t},r)=>(0,Ur.jsx)(qe.Action,{ref:r,className:R(Ks(),e),...t}));Ou.displayName=qe.Action.displayName;var Wu=ei.forwardRef(({className:e,...t},r)=>(0,Ur.jsx)(qe.Cancel,{ref:r,className:R(Ks({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));Wu.displayName=qe.Cancel.displayName;var af=Ae(require("react"),1),Zi=require("react/jsx-runtime"),pe=af.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,Zi.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,Zi.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,Zi.jsx)("input",{type:t,className:R("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,Zi.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));pe.displayName="Input";var wn=require("react");var dr=require("react");var sf=require("lucide-react");var Tr=require("react/jsx-runtime"),F2=a(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),lf=a(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,s]=(0,dr.useState)(()=>Fa(e)),[l,c]=(0,dr.useState)(e),u=(0,dr.useRef)(null),d=(0,dr.useRef)(null),f=(0,dr.useRef)(null),m=(0,dr.useRef)(!1),p=e!==n,v=(0,dr.useCallback)(y=>{m.current=!0;let b=V2(y);c(b),t(b),m.current=!1},[t]),h=a(y=>b=>{f.current=y,g(b)},"handleMouseDown"),g=(0,dr.useCallback)(y=>{if(f.current){if(f.current==="gradient"&&u.current){let b=u.current.getBoundingClientRect(),A=Math.max(0,Math.min(1,(y.clientX-b.left)/b.width)),x=Math.max(0,Math.min(1,(y.clientY-b.top)/b.height)),I={...i,s:A*100,v:(1-x)*100};s(I),v(I)}else if(f.current==="hue"&&d.current){let b=d.current.getBoundingClientRect(),A=Math.max(0,Math.min(1,(y.clientX-b.left)/b.width)),x={...i,h:A*360};s(x),v(x)}}},[i,v]),C=(0,dr.useCallback)(()=>{f.current=null},[]);(0,dr.useEffect)(()=>{if(f.current)return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[g,C]),(0,dr.useEffect)(()=>{m.current||(s(Fa(e)),c(e))},[e]);let P=a(y=>{let b=y.target.value;if(c(b),F2(b)){let A=Fa(b);s(A),v(A)}},"handleInputChange");return(0,Tr.jsxs)("div",{className:R("w-full",r),children:[(0,Tr.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,Tr.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,Tr.jsx)("div",{ref:d,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,Tr.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,Tr.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,Tr.jsx)(pe,{value:l,onChange:P,placeholder:"#000000",className:"courier-flex-1"}),p&&(0,Tr.jsx)("button",{onClick:y=>{if(y.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let b=Fa(n);s(b),v(b)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,Tr.jsx)(sf.CircleX,{size:14,strokeWidth:1.25})})]}),(0,Tr.jsx)(ye,{className:"courier-my-3"}),(0,Tr.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(y=>(0,Tr.jsx)("button",{className:R("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",y==="transparent"&&Uu),style:{backgroundColor:y==="transparent"?void 0:y},onClick:b=>{if(b.preventDefault(),y==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let A=Fa(y);s(A),v(A)}},y))})]})},"ColorPicker");function Fa(e){if(e==="transparent")return{h:0,s:0,v:0};let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,n=Math.max(t,r,o),i=Math.min(t,r,o),s=n-i,l=0,c=n===0?0:s/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/s+(r<o?6:0);break;case r:l=(o-t)/s+2;break;case o:l=(t-r)/s+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}a(Fa,"hexToHsv");function V2({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=a(l=>{let c=(l+e*6)%6;return r-r*t*Math.max(0,Math.min(c,4-c,1))},"f"),n=Math.round(o(5)*255),i=Math.round(o(3)*255),s=Math.round(o(1)*255);return`#${[n,i,s].map(l=>l.toString(16).padStart(2,"0")).join("")}`}a(V2,"hsvToHex");var zo=Ae(require("@radix-ui/react-popover"),1),cf=Ae(require("react"),1);var zu=require("react/jsx-runtime"),uf=zo.Root,df=zo.Trigger;var _u=cf.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:s,...l},c)=>(0,zu.jsx)(zo.Portal,{...s,children:(0,zu.jsx)(zo.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:R("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...l})}));_u.displayName=zo.Content.displayName;var on=require("react/jsx-runtime"),Uu="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",O2=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],lt=(0,wn.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=O2,...s},l)=>{let c=t!=="transparent",u=(0,wn.useRef)(null),d=(0,wn.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),f=(0,wn.useCallback)(()=>{var p;let m=(p=u.current)==null?void 0:p.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,on.jsxs)(uf,{children:[(0,on.jsx)(df,{asChild:!0,children:(0,on.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,on.jsx)("div",{className:R("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",c?"":Uu),style:{backgroundColor:c?t:void 0}}),(0,on.jsx)(pe,{...s,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:R("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,on.jsx)(_u,{portalProps:{container:typeof window!="undefined"?f():void 0},className:"courier-w-[230px]",children:(0,on.jsx)(lf,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});lt.displayName="InputColor";var mf=Ae(require("react"),1),$u=Ae(require("@radix-ui/react-separator"),1);var pf=require("react/jsx-runtime"),ju=mf.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,pf.jsx)($u.Root,{ref:n,decorative:r,orientation:t,className:R("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));ju.displayName=$u.Root.displayName;var ff=Ae(require("react"),1),nn=Ae(require("@radix-ui/react-slider"),1);var qi=require("react/jsx-runtime"),Zu=ff.forwardRef(({className:e,...t},r)=>(0,qi.jsxs)(nn.Root,{ref:r,className:R("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,qi.jsx)(nn.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,qi.jsx)(nn.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,qi.jsx)(nn.Thumb,{className:"courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-accent-foreground courier-shadow courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50"})]}));Zu.displayName=nn.Root.displayName;var gf=Ae(require("react"),1),Va=Ae(require("@radix-ui/react-switch"),1);var qu=require("react/jsx-runtime"),Ji=gf.forwardRef(({className:e,...t},r)=>(0,qu.jsx)(Va.Root,{className:R("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,qu.jsx)(Va.Thumb,{className:R("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));Ji.displayName=Va.Root.displayName;var tl=Ae(require("react"),1),vo=Ae(require("@radix-ui/react-tabs"),1);var nl=require("react/jsx-runtime"),rl=vo.Root,Oa=tl.forwardRef(({className:e,...t},r)=>(0,nl.jsx)(vo.List,{ref:r,className:R("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));Oa.displayName=vo.List.displayName;var Gi=tl.forwardRef(({className:e,...t},r)=>(0,nl.jsx)(vo.Trigger,{ref:r,className:R("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));Gi.displayName=vo.Trigger.displayName;var ol=tl.forwardRef(({className:e,...t},r)=>(0,nl.jsx)(vo.Content,{ref:r,className:R("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));ol.displayName=vo.Content.displayName;var Ki=Ae(require("react"),1);var hf=require("react/jsx-runtime"),Ju=Ki.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=Ki.useRef(null),i=a(s=>{n.current=s,typeof o=="function"?o(s):o&&(o.current=s)},"combinedRef");return Ki.useEffect(()=>{if(!t)return;let s=n.current;if(!s)return;let l=a(()=>{s.style.height="auto",s.style.height=`${s.scrollHeight}px`},"adjustHeight");return l(),s.addEventListener("input",l),()=>{s.removeEventListener("input",l)}},[t]),(0,hf.jsx)("textarea",{className:R("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});Ju.displayName="Textarea";var Ku=require("react");var vf=require("react");var il={colorScheme:"light",background:"#ffffff",foreground:"#404040",muted:"#D9D9D9",mutedForeground:"#A3A3A3",popover:"#ffffff",popoverForeground:"#292929",border:"#DCDEE4",input:"#DCDEE4",card:"#FAF9F8",cardForeground:"#292929",primary:"#ffffff",primaryForeground:"#696F8C",secondary:"#F5F5F5",secondaryForeground:"#171717",accent:"#E5F3FF",accentForeground:"#1D4ED8",destructive:"#292929",destructiveForeground:"#FF3363",ring:"#80849D",radius:"6px"},bf={...il},yf={...il,colorScheme:"dark",foreground:"#d4d4d4",background:"#262626",card:"#262626",primary:"#262626"};var Cf=(0,vf.createContext)(il);var Gu=require("react/jsx-runtime"),xf=(0,Ku.forwardRef)(({children:e,theme:t,dataMode:r="light",className:o},n)=>{let i=r==="light"?bf:yf,s=i;t&&(s=typeof t=="string"?t:{...i,...t});let l=typeof t=="string"?{}:Object.entries(s).reduce((c,[u,d])=>{let f=u.replace(/[A-Z]/g,m=>`-${m.toLowerCase()}`);return{...c,[`--${f}`]:d}},{});return(0,Gu.jsx)(Cf.Provider,{value:typeof s=="object"?s:{},children:(0,Gu.jsx)("div",{style:l,className:R("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",o),ref:n,children:e})})});var Tf=Ae(require("react"),1),Yu=Ae(require("@radix-ui/react-toggle"),1),wf=require("class-variance-authority");var Ef=require("react/jsx-runtime"),Xu=(0,wf.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),W2=Tf.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,Ef.jsx)(Yu.Root,{ref:n,className:R(Xu({variant:t,size:r,className:e})),...o}));W2.displayName=Yu.Root.displayName;var Yi=Ae(require("@radix-ui/react-toggle-group"),1),ti=Ae(require("react"),1);var al=require("react/jsx-runtime"),Pf=ti.createContext({size:"default",variant:"default"}),er=ti.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,al.jsx)(Yi.Root,{ref:i,className:R("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,al.jsx)(Pf.Provider,{value:{variant:t,size:r},children:o})}));er.displayName=Yi.Root.displayName;var tt=ti.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let s=ti.useContext(Pf);return(0,al.jsx)(Yi.Item,{ref:i,className:R(Xu({variant:s.variant||r,size:s.size||o}),e),...n,children:t})});tt.displayName=Yi.Item.displayName;var sl=require("react/jsx-runtime"),Ue=a(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,sl.jsx)("path",{className:R(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,sl.jsx)("path",{className:R(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),X=a(({width:e=28,height:t=28,...r})=>(0,sl.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var Xi=require("react/jsx-runtime"),kf=a(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,Xi.jsxs)(X,{...o,width:t,height:r,children:[(0,Xi.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,Xi.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,Xi.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var Qu=require("react/jsx-runtime"),Wa=a(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,Qu.jsx)(X,{...o,fill:"none",width:t,height:r,children:(0,Qu.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var ed=require("react/jsx-runtime"),an=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,ed.jsx)(X,{...n,width:r,height:o,children:(0,ed.jsx)(Ue,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var Qi=require("react/jsx-runtime"),zr=a(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,Qi.jsxs)(X,{...o,width:t,height:r,children:[(0,Qi.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,Qi.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,Qi.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var td=require("react/jsx-runtime"),rd=a(({color:e,width:t=21,height:r=16,...o})=>(0,td.jsx)(X,{...o,width:t,height:r,children:(0,td.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var od=require("react/jsx-runtime"),nd=a(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,od.jsx)(X,{...o,fill:"none",width:t,height:r,children:(0,od.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var id=require("react/jsx-runtime"),ad=a(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,id.jsx)(X,{...n,width:t,height:r,viewBox:o,children:(0,id.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var sd=require("react/jsx-runtime"),Ua=a(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,sd.jsx)(X,{...o,width:t,height:r,children:(0,sd.jsx)(Ue,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var ld=require("react/jsx-runtime"),za=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,ld.jsx)(X,{...n,width:r,height:o,children:(0,ld.jsx)(Ue,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var cd=require("react/jsx-runtime"),ud=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,cd.jsx)(X,{...o,width:t,height:r,children:(0,cd.jsx)(Ue,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var dd=require("react/jsx-runtime"),_a=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,dd.jsx)(X,{...o,width:t,height:r,children:(0,dd.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var md=require("react/jsx-runtime"),$a=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,md.jsx)(X,{...n,width:r,height:o,children:(0,md.jsx)(Ue,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var pd=require("react/jsx-runtime"),ja=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,pd.jsx)(X,{...n,width:r,height:o,children:(0,pd.jsx)(Ue,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var fd=require("react/jsx-runtime"),gd=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,fd.jsx)(X,{...n,width:t,height:r,viewBox:o,children:(0,fd.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var hd=require("react/jsx-runtime"),Za=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,hd.jsx)(X,{...n,width:r,height:o,children:(0,hd.jsx)(Ue,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var ll=require("react/jsx-runtime"),bd=a(({color:e,width:t=21,height:r=16,...o})=>(0,ll.jsx)(X,{...o,width:t,height:r,children:(0,ll.jsx)("g",{transform:"translate(4, 0)",children:(0,ll.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var yd=require("react/jsx-runtime"),vd=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,yd.jsx)(X,{...o,width:t,height:r,children:(0,yd.jsx)(Ue,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var Cd=require("react/jsx-runtime"),ri=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Cd.jsx)(X,{...n,width:r,height:o,children:(0,Cd.jsx)(Ue,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var xd=require("react/jsx-runtime"),sn=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,xd.jsx)(X,{...n,width:r,height:o,children:(0,xd.jsx)(Ue,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var qa=require("react/jsx-runtime"),Td=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 20 21",...n})=>(0,qa.jsxs)(X,{...n,width:t,height:r,viewBox:o,children:[(0,qa.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:e}),(0,qa.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:e,stroke:"white","stroke-width":"2"})]}),"PushIcon");var wd=require("react/jsx-runtime"),Ed=a(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,wd.jsx)(X,{...o,fill:"none",width:t,height:r,children:(0,wd.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var Pd=require("react/jsx-runtime"),kd=a(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,Pd.jsx)(X,{...o,width:t,height:r,children:(0,Pd.jsx)(Ue,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var Md=require("react/jsx-runtime"),Nd=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Md.jsx)(X,{...o,width:t,height:r,children:(0,Md.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var En=require("react/jsx-runtime"),Mf=a(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,En.jsx)(X,{...o,width:t,height:r,children:(0,En.jsxs)("g",{opacity:"0.9",children:[(0,En.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,En.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,En.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,En.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var Ad=require("react/jsx-runtime"),Sd=a(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Ad.jsx)(X,{...o,width:t,height:r,children:(0,Ad.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var Id=require("react/jsx-runtime"),Ja=a(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,Id.jsx)(X,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,Id.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var Ld=require("react/jsx-runtime"),Ga=a(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,Ld.jsx)(X,{...o,width:t,height:r,children:(0,Ld.jsx)(Ue,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var oi=require("react/jsx-runtime"),Nf=a(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,oi.jsx)(X,{...o,width:t,height:r,children:(0,oi.jsxs)("g",{opacity:"0.9",children:[(0,oi.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,oi.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,oi.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var Rd=require("react/jsx-runtime"),Ka=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Rd.jsx)(X,{...n,width:r,height:o,children:(0,Rd.jsx)(Ue,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var Af=require("lucide-react"),ai=require("react");var cl=require("react/jsx-runtime"),ni=a(({className:e})=>(0,cl.jsx)("div",{className:R("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,cl.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,cl.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var ii=require("react/jsx-runtime"),ea=a(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[s,l]=(0,ai.useState)(!1),c=(0,ai.useRef)(t),u=(0,ai.useRef)(null);return(0,ai.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,ii.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ii.jsx)(ni,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,ii.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):s?i?i(s):(0,ii.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ii.jsx)(Af.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var Dd=require("jotai");var si=require("react/jsx-runtime"),Pn=[{label:"Email",value:"email",icon:(0,si.jsx)(ad,{})},{label:"SMS",value:"sms",icon:(0,si.jsx)(Nd,{})},{label:"Push",value:"push",icon:(0,si.jsx)(Td,{})},{label:"In-app",value:"inbox",icon:(0,si.jsx)(_a,{})},{label:"Slack",value:"slack",icon:(0,si.jsx)(Sd,{})},{label:"Teams",value:"msteams",icon:(0,si.jsx)(gd,{})}];var kn=(0,Dd.atom)("email"),ta=(0,Dd.atom)("template");var Zb=require("@radix-ui/react-alert-dialog"),Cn=require("jotai"),Yo=require("react");var wr=require("jotai");var Hd={contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},ul=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"}};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"}};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var U2={paragraph:Hd,heading:Hd},Ya=(0,wr.atom)(U2),Me=(0,wr.atom)(null),ft=(0,wr.atom)(null,(e,t,r)=>{t(Me,r)}),z2=(0,wr.atom)({ref:null,caretPosition:null}),dl=(0,wr.atom)({ref:null,caretPosition:null}),Xa=(0,wr.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),Sf=(0,wr.atom)(e=>(t,r=!1)=>{let o=e(Ya),n=e(Xa),i=ul(t,r),s=o[t],l=i;return s&&Object.keys(s).forEach(c=>{var d,f;let u=c;((d=i[u])==null?void 0:d.state)==="enabled"&&((f=s[u])==null?void 0:f.state)==="enabled"&&(l[u]=s[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),If=(0,wr.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(Ya);t(Ya,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).map(([i,s])=>[i,{state:(s==null?void 0:s.state)||"hidden"}]))}})}),Y4=(0,wr.atom)(null,(e,t,r)=>{let o=e(Ya),{[r]:n,...i}=o;t(Ya,i)}),Lf=(0,wr.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(z2,{ref:r,caretPosition:o})}),X4=(0,wr.atom)(null,(e,t,r)=>{let o=e(Xa);t(Xa,{...o,showVariablePopup:r})}),Bd=(0,wr.atom)(null),ml=(0,wr.atom)(null,(e,t,r)=>{t(Bd,r)});var vn=require("jotai"),Or=require("react");var Fd=require("jotai"),Co=(0,Fd.atom)(null),_o=(0,Fd.atom)(null);var Rf=require("react"),Df=require("sonner");var Mn=require("react/jsx-runtime"),Er=(0,Rf.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,dataMode:n="light",className:i,...s},l)=>(0,Mn.jsx)(xf,{theme:e,ref:l,dataMode:n,className:i,children:(0,Mn.jsxs)("div",{...Object.fromEntries(Object.entries(s).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,Mn.jsx)("div",{className:"courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-primary",children:o}),r&&(0,Mn.jsx)("div",{className:"courier-editor-loading",children:(0,Mn.jsx)(ni,{})}),(0,Mn.jsx)(Df.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var Ar=require("jotai"),De=require("react");function Hf(e){if(Array.isArray(e))return e}a(Hf,"_arrayWithHoles");function Bf(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,s,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(d){u=!0,n=d}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}a(Bf,"_iterableToArrayLimit");function Qa(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(Qa,"_arrayLikeToArray");function pl(e,t){if(e){if(typeof e=="string")return Qa(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qa(e,t):void 0}}a(pl,"_unsupportedIterableToArray");function Ff(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
182
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(Ff,"_nonIterableRest");function fl(e,t){return Hf(e)||Bf(e,t)||pl(e,t)||Ff()}a(fl,"_slicedToArray");var x1=Ae(es());var hl="data-pdnd-honey-pot";function bl(e){return e instanceof Element&&e.hasAttribute(hl)}a(bl,"isHoneyPotElement");function yl(e){var t=document.elementsFromPoint(e.x,e.y),r=fl(t,2),o=r[0],n=r[1];return o?bl(o)?n!=null?n:null:o:null}a(yl,"getElementFromPointWithoutHoneypot");function li(e){"@babel/helpers - typeof";return li=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},li(e)}a(li,"_typeof");function Wf(e,t){if(li(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(li(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}a(Wf,"toPrimitive");function Uf(e){var t=Wf(e,"string");return li(t)=="symbol"?t:t+""}a(Uf,"toPropertyKey");function ln(e,t,r){return(t=Uf(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(ln,"_defineProperty");var rs=Ae(es());var zf=2147483647;function _f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(_f,"ownKeys");function $f(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_f(Object(r),!0).forEach(function(o){ln(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_f(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a($f,"_objectSpread");var ts=2,jf=ts/2;function G2(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}a(G2,"floorToClosestPixel");function K2(e){return{x:e.x-jf,y:e.y-jf}}a(K2,"pullBackByHalfHoneyPotSize");function Y2(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}a(Y2,"preventGoingBackwardsOffScreen");function X2(e){return{x:Math.min(e.x,window.innerWidth-ts),y:Math.min(e.y,window.innerHeight-ts)}}a(X2,"preventGoingForwardsOffScreen");function Zf(e){var t=e.client,r=X2(Y2(K2(G2(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:ts,height:ts})}a(Zf,"getHoneyPotRectFor");function qf(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}a(qf,"getRectStyles");function Q2(e){var t=e.client,r=e.clientRect;return t.x>=r.x&&t.x<=r.x+r.width&&t.y>=r.y&&t.y<=r.y+r.height}a(Q2,"isWithin");function e0(e){var t=e.initial,r=document.createElement("div");r.setAttribute(hl,"true");var o=Zf({client:t});Object.assign(r.style,$f($f({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},qf({clientRect:o})),{},{pointerEvents:"auto",zIndex:zf})),document.body.appendChild(r);var n=(0,rs.bind)(window,{type:"pointermove",listener:a(function(s){var l={x:s.clientX,y:s.clientY};o=Zf({client:l}),Object.assign(r.style,qf({clientRect:o}))},"listener"),options:{capture:!0}});return a(function(s){var l=s.current;if(n(),Q2({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}a(c,"cleanup");var u=(0,rs.bindAll)(window,[{type:"pointerdown",listener:c},{type:"pointermove",listener:c},{type:"focusin",listener:c},{type:"focusout",listener:c},{type:"dragstart",listener:c},{type:"dragenter",listener:c},{type:"dragover",listener:c}],{capture:!0})},"finish")}a(e0,"mountHoneyPot");function Jf(){var e=null;function t(){return e=null,(0,rs.bind)(window,{type:"pointermove",listener:a(function(n){e={x:n.clientX,y:n.clientY}},"listener"),options:{capture:!0}})}a(t,"bindEvents");function r(){var o=null;return a(function(i){var s=i.eventName,l=i.payload;if(s==="onDragStart"){var c=l.location.initial.input,u=e!=null?e:{x:c.clientX,y:c.clientY};o=e0({initial:u})}if(s==="onDrop"){var d,f=l.location.current.input;(d=o)===null||d===void 0||d({current:{x:f.clientX,y:f.clientY}}),o=null,e=null}},"onPostEvent")}return a(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}a(Jf,"makeHoneyPotFix");function Gf(e){if(Array.isArray(e))return Qa(e)}a(Gf,"_arrayWithoutHoles");function Kf(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}a(Kf,"_iterableToArray");function Yf(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
183
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(Yf,"_nonIterableSpread");function vl(e){return Gf(e)||Kf(e)||pl(e)||Yf()}a(vl,"_toConsumableArray");var a1=Ae(es());function ro(e){var t=null;return a(function(){if(!t){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];var s=e.apply(this,n);t={result:s}}return t.result},"wrapped")}a(ro,"once");var Xf=ro(a(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var os=ro(a(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Qf=Ae(es());var Od={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function e1(e){var t=e.dragLeave;return os()?t.hasOwnProperty(Od.isLeavingWindow):!1}a(e1,"isLeavingWindowInSafari");a(function(){if(typeof window=="undefined"||!os())return;function t(){return{enterCount:0,isOverWindow:!1}}a(t,"getInitialState");var r=t();function o(){r=t()}a(o,"resetState"),(0,Qf.bindAll)(window,[{type:"dragstart",listener:a(function(){r.enterCount=0,r.isOverWindow=!0},"listener")},{type:"drop",listener:o},{type:"dragend",listener:o},{type:"dragenter",listener:a(function(i){!r.isOverWindow&&r.enterCount===0&&(i[Od.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:a(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[Od.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function t0(e){return"nodeName"in e}a(t0,"isNodeLike");function t1(e){return t0(e)&&e.ownerDocument!==document}a(t1,"isFromAnotherWindow");function r1(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:os()?e1({dragLeave:t}):o==null?!0:Xf()?t1(o):o instanceof HTMLIFrameElement}a(r1,"isLeavingWindow");function o1(e){var t=e.onDragEnd;return[{type:"pointermove",listener:function(){var r=0;return a(function(){if(r<20){r++;return}t()},"listener")}()},{type:"pointerdown",listener:t}]}a(o1,"getBindingsForBrokenDrags");function ci(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}a(ci,"getInput");var r0=a(function(t){var r=[],o=null,n=a(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];r=l,!o&&(o=requestAnimationFrame(function(){o=null,t.apply(void 0,r)}))},"wrapperFn");return n.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},n},"rafSchd"),n1=r0;var Wd=n1(function(e){return e()}),Cl=function(){var e=null;function t(o){var n=requestAnimationFrame(function(){e=null,o()});e={frameId:n,fn:o}}a(t,"schedule");function r(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return a(r,"flush"),{schedule:t,flush:r}}();function i1(e){var t=e.source,r=e.initial,o=e.dispatchEvent,n={dropTargets:[]};function i(l){o(l),n={dropTargets:l.payload.location.current.dropTargets}}a(i,"safeDispatch");var s={start:a(function(c){var u=c.nativeSetDragImage,d={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),Cl.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:a(function(c){var u=c.current;Cl.flush(),Wd.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:a(function(c){var u=c.current;Wd(function(){Cl.flush();var d={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:d}})})},"drag"),drop:a(function(c){var u=c.current,d=c.updatedSourcePayload;Cl.flush(),Wd.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return s}a(i1,"makeDispatch");var zd={isActive:!1};function s1(){return!zd.isActive}a(s1,"canStart");function o0(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}a(o0,"getNativeSetDragImage");function n0(e){var t=e.current,r=e.next;if(t.length!==r.length)return!0;for(var o=0;o<t.length;o++)if(t[o].element!==r[o].element)return!0;return!1}a(n0,"hasHierarchyChanged");function i0(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!s1())return;var i=a0({event:t,dragType:r,getDropTargetsOver:o});zd.isActive=!0;var s={current:i};Ud({event:t,current:i.dropTargets});var l=i1({source:r.payload,dispatchEvent:n,initial:i});function c(p){var v=n0({current:s.current.dropTargets,next:p.dropTargets});s.current=p,v&&l.dragUpdate({current:s.current})}a(c,"updateState");function u(p){var v=ci(p),h=bl(p.target)?yl({x:v.clientX,y:v.clientY}):p.target,g=o({target:h,input:v,source:r.payload,current:s.current.dropTargets});g.length&&(p.preventDefault(),Ud({event:p,current:g})),c({dropTargets:g,input:v})}a(u,"onUpdateEvent");function d(){s.current.dropTargets.length&&c({dropTargets:[],input:s.current.input}),l.drop({current:s.current,updatedSourcePayload:null}),f()}a(d,"cancel");function f(){zd.isActive=!1,m()}a(f,"finish");var m=(0,a1.bindAll)(window,[{type:"dragover",listener:a(function(v){u(v),l.drag({current:s.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:a(function(v){r1({dragLeave:v})&&(c({input:s.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:a(function(v){if(s.current={dropTargets:s.current.dropTargets,input:ci(v)},!s.current.dropTargets.length){d();return}v.preventDefault(),Ud({event:v,current:s.current.dropTargets}),l.drop({current:s.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(v):null}),f()},"listener")},{type:"dragend",listener:a(function(v){s.current={dropTargets:s.current.dropTargets,input:ci(v)},d()},"listener")}].concat(vl(o1({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:o0(t)})}a(i0,"start");function Ud(e){var t,r=e.event,o=e.current,n=(t=o[0])===null||t===void 0?void 0:t.dropEffect;n!=null&&r.dataTransfer&&(r.dataTransfer.dropEffect=n)}a(Ud,"setDropEffectOnEvent");function a0(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=ci(t);if(r.startedFrom==="external")return{input:n,dropTargets:[]};var i=o({input:n,source:r.payload,target:t.target,current:[]});return{input:n,dropTargets:i}}a(a0,"getStartLocation");var _d={canStart:s1,start:i0};var $d=new Map;function s0(e){var t=e.typeKey,r=e.mount,o=$d.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return $d.set(t,n),n}a(s0,"registerUsage");function l1(e){var t=s0(e);return a(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),$d.delete(e.typeKey))},"unregister")}a(l1,"register");function $o(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return a(function(){t.forEach(function(n){return n()})},"cleanup")}a($o,"combine");function xl(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}a(xl,"addAttribute");function c1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(c1,"ownKeys");function Nn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?c1(Object(r),!0).forEach(function(o){ln(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(Nn,"_objectSpread");function jd(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=l0(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
184
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(jd,"_createForOfIteratorHelper");function l0(e,t){if(e){if(typeof e=="string")return u1(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u1(e,t):void 0}}a(l0,"_unsupportedIterableToArray");function u1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(u1,"_arrayLikeToArray");function Zd(e){return e.slice(0).reverse()}a(Zd,"copyReverse");function d1(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function s(p){return o.set(p.element,p),function(){return o.delete(p.element)}}a(s,"addToRegistry");function l(p){if(0)var v;var h=$o(xl(p.element,{attribute:n,value:"true"}),s(p));return ro(h)}a(l,"dropTargetForConsumers");function c(p){var v,h,g,C,P=p.source,y=p.target,b=p.input,A=p.result,x=A===void 0?[]:A;if(y==null)return x;if(!(y instanceof Element))return y instanceof Node?c({source:P,target:y.parentElement,input:b,result:x}):x;var I=y.closest(i);if(I==null)return x;var T=o.get(I);if(T==null)return x;var k={input:b,source:P,element:T.element};if(T.canDrop&&!T.canDrop(k))return c({source:P,target:T.element.parentElement,input:b,result:x});var w=(v=(h=T.getData)===null||h===void 0?void 0:h.call(T,k))!==null&&v!==void 0?v:{},E=(g=(C=T.getDropEffect)===null||C===void 0?void 0:C.call(T,k))!==null&&g!==void 0?g:r,N={data:w,element:T.element,dropEffect:E,isActiveDueToStickiness:!1};return c({source:P,target:T.element.parentElement,input:b,result:[].concat(vl(x),[N])})}a(c,"getActualDropTargets");function u(p){var v=p.eventName,h=p.payload,g=jd(h.location.current.dropTargets),C;try{for(g.s();!(C=g.n()).done;){var P,y=C.value,b=o.get(y.element),A=Nn(Nn({},h),{},{self:y});b==null||(P=b[v])===null||P===void 0||P.call(b,A)}}catch(x){g.e(x)}finally{g.f()}}a(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:a(function(v){var h=v.payload,g=new Set(h.location.current.dropTargets.map(function(B){return B.element})),C=new Set,P=jd(h.location.previous.dropTargets),y;try{for(P.s();!(y=P.n()).done;){var b,A=y.value;C.add(A.element);var x=o.get(A.element),I=g.has(A.element),T=Nn(Nn({},h),{},{self:A});if(x==null||(b=x.onDropTargetChange)===null||b===void 0||b.call(x,T),!I){var k;x==null||(k=x.onDragLeave)===null||k===void 0||k.call(x,T)}}}catch(B){P.e(B)}finally{P.f()}var w=jd(h.location.current.dropTargets),E;try{for(w.s();!(E=w.n()).done;){var N,M,S=E.value;if(!C.has(S.element)){var D=Nn(Nn({},h),{},{self:S}),L=o.get(S.element);L==null||(N=L.onDropTargetChange)===null||N===void 0||N.call(L,D),L==null||(M=L.onDragEnter)===null||M===void 0||M.call(L,D)}}}catch(B){w.e(B)}finally{w.f()}},"onDropTargetChange")};function f(p){d[p.eventName](p)}a(f,"dispatchEvent");function m(p){var v=p.source,h=p.target,g=p.input,C=p.current,P=c({source:v,target:h,input:g});if(P.length>=C.length)return P;for(var y=Zd(C),b=Zd(P),A=[],x=0;x<y.length;x++){var I,T=y[x],k=b[x];if(k!=null){A.push(k);continue}var w=A[x-1],E=y[x-1];if((w==null?void 0:w.element)!==(E==null?void 0:E.element))break;var N=o.get(T.element);if(!N)break;var M={input:g,source:v,element:N.element};if(N.canDrop&&!N.canDrop(M)||!((I=N.getIsSticky)!==null&&I!==void 0&&I.call(N,M)))break;A.push(Nn(Nn({},T),{},{isActiveDueToStickiness:!0}))}return Zd(A)}return a(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:f}}a(d1,"makeDropTarget");function c0(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=u0(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
185
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(c0,"_createForOfIteratorHelper");function u0(e,t){if(e){if(typeof e=="string")return m1(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m1(e,t):void 0}}a(u0,"_unsupportedIterableToArray");function m1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(m1,"_arrayLikeToArray");function p1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(p1,"ownKeys");function d0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?p1(Object(r),!0).forEach(function(o){ln(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(d0,"_objectSpread");function f1(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}a(r,"tryAddToActive");function o(i){var s=d0({},i);e.add(s),r(s);function l(){e.delete(s),t&&t.active.delete(s)}return a(l,"cleanup"),ro(l)}a(o,"monitorForConsumers");function n(i){var s=i.eventName,l=i.payload;if(s==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=c0(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(g){c.e(g)}finally{c.f()}}if(t){for(var f=Array.from(t.active),m=0,p=f;m<p.length;m++){var v=p[m];if(t.active.has(v)){var h;(h=v[s])===null||h===void 0||h.call(v,l)}}s==="onDrop"&&(t.active.clear(),t=null)}}return a(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}a(f1,"makeMonitor");function g1(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,s=f1(),l=d1({typeKey:t,defaultDropEffect:i});function c(f){o==null||o(f),l.dispatchEvent(f),s.dispatchEvent(f),n==null||n(f)}a(c,"dispatchEvent");function u(f){var m=f.event,p=f.dragType;_d.start({event:m,dragType:p,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}a(u,"start");function d(){function f(){var m={canStart:_d.canStart,start:u};return r(m)}return a(f,"mountAdapter"),l1({typeKey:t,mount:f})}return a(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:s.monitorForConsumers}}a(g1,"makeAdapter");var h1=ro(a(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),b1="pdnd:android-fallback";var qd="text/plain";var y1="text/uri-list";var v1="application/vnd.pdnd";var Tl=new WeakMap;function m0(e){return Tl.set(e.element,e),a(function(){Tl.delete(e.element)},"cleanup")}a(m0,"addToRegistry");var C1=Jf(),Jd=g1({typeKey:"element",defaultDropEffect:"move",mount:a(function(t){return $o(C1.bindEvents(),(0,x1.bind)(document,{type:"dragstart",listener:a(function(o){var n,i,s,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var f=Tl.get(d);if(f){var m=ci(o),p={element:f.element,dragHandle:(n=f.dragHandle)!==null&&n!==void 0?n:null,input:m};if(f.canDrag&&!f.canDrag(p)){o.preventDefault();return}if(f.dragHandle){var v=yl({x:m.clientX,y:m.clientY});if(!f.dragHandle.contains(v)){o.preventDefault();return}}var h=(i=(s=f.getInitialDataForExternal)===null||s===void 0?void 0:s.call(f,p))!==null&&i!==void 0?i:null;if(h)for(var g=0,C=Object.entries(h);g<C.length;g++){var P=fl(C[g],2),y=P[0],b=P[1];o.dataTransfer.setData(y,b!=null?b:"")}h1()&&!o.dataTransfer.types.includes(qd)&&!o.dataTransfer.types.includes(y1)&&o.dataTransfer.setData(qd,b1),o.dataTransfer.setData(v1,"");var A={element:f.element,dragHandle:(l=f.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=f.getInitialData)===null||u===void 0?void 0:u.call(f,p))!==null&&c!==void 0?c:{}},x={type:"element",payload:A,startedFrom:"internal"};t.start({event:o,dragType:x})}}}},"listener")}))},"mount"),dispatchEventToSource:a(function(t){var r,o,n=t.eventName,i=t.payload;(r=Tl.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:C1.getOnPostDispatch()}),_r=Jd.dropTarget,Gd=Jd.monitor;function ns(e){if(0)var t;var r=$o(Jd.registerUsage(),m0(e),xl(e.element,{attribute:"draggable",value:"true"}));return ro(r)}a(ns,"draggable");function T1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(T1,"ownKeys");function w1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?T1(Object(r),!0).forEach(function(o){ln(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(w1,"_objectSpread");var p0={top:a(function(t,r){return Math.abs(r.y-t.top)},"top"),right:a(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:a(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:a(function(t,r){return Math.abs(r.x-t.left)},"left")},E1=Symbol("closestEdge");function P1(e,t){var r,o,n=t.element,i=t.input,s=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=s.map(function(f){return{edge:f,value:p0[f](c,l)}}),d=(r=(o=u.sort(function(f,m){return f.value-m.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return w1(w1({},e),{},ln({},E1,d))}a(P1,"attachClosestEdge");function is(e){var t;return(t=e[E1])!==null&&t!==void 0?t:null}a(is,"extractClosestEdge");var Rc=require("@tiptap/core"),E5=require("@tiptap/react");var C5=require("@tiptap/react"),x5=require("jotai"),T5=require("react");var b5=require("@tiptap/react"),y5=require("jotai"),Ve=require("react"),v5=require("uuid");var Wm=require("@tiptap/extension-color");var k1=require("@tiptap/core"),M1=require("@tiptap/pm/dropcursor"),Kd=k1.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,M1.dropCursor)(this.options)]}});var Um=require("@tiptap/extension-hard-break");var N1=require("@tiptap/core"),ia=require("@tiptap/pm/history"),f0=N1.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,ia.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,ia.redo)(e,t)}},addProseMirrorPlugins(){return[(0,ia.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var zm=require("@tiptap/extension-placeholder"),_m=require("@tiptap/extension-text-align"),$m=require("@tiptap/extension-typography"),jm=require("@tiptap/extension-underline"),Zm=require("@tiptap/starter-kit");var L1=require("@tiptap/core");var aa=require("@tiptap/core"),g0=/^\s*>\s$/,A1=aa.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,aa.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,aa.wrappingInputRule)({find:g0,type:this.type})]}});var R1=require("@tiptap/react");var S1=require("uuid");function St(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let s=`node-${(0,S1.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:s}),o=!0}return!1}),o&&e.view.dispatch(r)}a(St,"generateNodeIds");var wl=require("@tiptap/react"),El=require("jotai"),sa=require("react");var An=require("react/jsx-runtime"),h0=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,An.jsx)("div",{className:"courier-w-full node-element",children:(0,An.jsx)("div",{style:{zIndex:-15,position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,An.jsx)(wl.NodeViewContent,{})})}),"BlockquoteComponent"),I1=a(e=>{var l,c,u;let t=(0,El.useSetAtom)(ft),r=(0,El.useAtomValue)(Me),o=(0,sa.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,sa.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,sa.useEffect)(()=>{let d=o.current;if(!d)return;let f=a(m=>{let p=m.target;p.closest(".courier-actions-panel")||p.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",f,!0),()=>{d.removeEventListener("click",f,!0)}},[i]);let s=!e.node.content||e.node.content.size===0;return(0,An.jsx)(wl.NodeViewWrapper,{children:(0,An.jsx)("div",{ref:o,children:(0,An.jsx)(tr,{id:e.node.attrs.id,className:R(n&&"selected-element",s&&"is-empty"),editor:e.editor,children:(0,An.jsx)(h0,{...e.node.attrs})})})})},"BlockquoteComponentNode");var cn={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},Yd=A1.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){St(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:cn.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:cn.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:cn.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:cn.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:cn.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,L1.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let s=i.selection.from,l=i.doc.resolve(s);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,R1.ReactNodeViewRenderer)(I1)}});var W1=require("@hookform/resolvers/zod"),U1=require("react-hook-form");var ui=require("react");var zt=a(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,ui.useRef)(null),i=(0,ui.useRef)(null);return(0,ui.useEffect)(()=>{if(!e||!t)return;let l=a(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,f])=>{r.getValues(d)!==f&&r.setValue(d,f)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,ui.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:f,dispatch:m})=>{let p=f.doc.nodeAt(i.current);return(p==null?void 0:p.type.name)===o&&m?(f.setNodeMarkup(i.current,p.type,u),f.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var di=require("jotai"),as=require("react");var $r=a((e={},t="")=>Object.entries(e).reduce((r,[o,n])=>{let i=t?`${t}.${o}`:o;return n&&typeof n=="object"&&!Array.isArray(n)?[...r,...$r(n,i)]:[...r,i]},[]),"getFlattenedVariables");var b0={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},y0=["content","href","src","title"],D1=a((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=a(i=>{let s=i.matchAll(r);for(let l of s){let c=l[1].trim();c&&ur(c)&&t.add(c)}},"extractFromString"),n=a(i=>{let s=i;s.type==="string"&&typeof s.content=="string"&&o(s.content),s.type==="text"&&typeof s.content=="string"&&o(s.content);let l=s.type,c=b0[l];c&&c.forEach(u=>{typeof s[u]=="string"&&o(s[u])}),typeof s.if=="string"&&o(s.if),typeof s.loop=="string"&&o(s.loop),s.type==="channel"&&s.raw&&typeof s.raw=="object"&&s.raw!==null&&Object.values(s.raw).forEach(u=>{typeof u=="string"&&o(u)}),s.elements&&Array.isArray(s.elements)&&s.elements.forEach(u=>n(u)),s.locales&&typeof s.locales=="object"&&s.locales!==null&&Object.values(s.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;y0.forEach(f=>{typeof d[f]=="string"&&o(d[f])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(f=>{f&&n(f)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(f=>{typeof f=="string"&&o(f)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var v0=a(e=>{let t=(0,di.useAtomValue)(_e),r=(0,di.useAtomValue)(se),o=(0,di.useAtomValue)(kn),n=(0,di.useAtomValue)(Xn),i=(0,di.useSetAtom)(Xn),s=e!=null?e:o,l=(0,as.useMemo)(()=>{var f,m;if(!t)return[];let d=((m=(f=t.extensionManager.extensions.find(p=>p.name==="variableSuggestion"))==null?void 0:f.options)==null?void 0:m.variables)||{};return $r(d)},[t]),c=(0,as.useMemo)(()=>{if(!r||!s)return[];let d=r.elements.find(f=>f.type==="channel"&&f.channel===s);return d?D1(d.elements||[]):[]},[r,s]),u=(0,as.useCallback)((d,f)=>{i(m=>({...m,[d]:f}))},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u}},"useVariables");var V1=require("jotai");var ss=require("react/jsx-runtime"),It=a(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,ss.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,ss.jsx)("div",{className:R("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-[#F5F5F5]":"courier-border"),children:t}),(0,ss.jsx)("span",{className:"courier-text-sm courier-font-medium",children:e?r:o})]}),"BlockBase");var H1=require("lucide-react");var Xd=require("react/jsx-runtime"),B1=a(({draggable:e=!1})=>(0,Xd.jsx)(It,{draggable:e,icon:(0,Xd.jsx)(H1.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var ls=require("react/jsx-runtime"),C0=a(()=>(0,ls.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ls.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"#171717"})}),"ButtonBlockIcon"),Sn=a(({draggable:e=!1})=>(0,ls.jsx)(It,{draggable:e,icon:(0,ls.jsx)(C0,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var cs=require("react/jsx-runtime"),x0=a(()=>(0,cs.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,cs.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"#171717"})}),"ColumnBlockIcon"),Pl=a(({draggable:e=!1})=>(0,cs.jsx)(It,{draggable:e,icon:(0,cs.jsx)(x0,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var us=require("react/jsx-runtime"),T0=a(()=>(0,us.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,us.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"#171717",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),ds=a(({draggable:e=!1})=>(0,us.jsx)(It,{draggable:e,icon:(0,us.jsx)(T0,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var ms=require("react/jsx-runtime"),w0=a(()=>(0,ms.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ms.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"#171717"})}),"DividerBlockIcon"),In=a(({draggable:e=!1})=>(0,ms.jsx)(It,{draggable:e,icon:(0,ms.jsx)(w0,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var ps=require("react/jsx-runtime"),E0=a(()=>(0,ps.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ps.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"#171717"})}),"HeadingBlockIcon"),kl=a(({draggable:e=!1})=>(0,ps.jsx)(It,{draggable:e,icon:(0,ps.jsx)(E0,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var fs=require("react/jsx-runtime"),P0=a(()=>(0,fs.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,fs.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"#171717"})}),"ImageBlockIcon"),Ml=a(({draggable:e=!1})=>(0,fs.jsx)(It,{draggable:e,icon:(0,fs.jsx)(P0,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var F1=require("lucide-react");var Qd=require("react/jsx-runtime"),Nl=a(({draggable:e=!1})=>(0,Qd.jsx)(It,{draggable:e,icon:(0,Qd.jsx)(F1.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var gs=require("react/jsx-runtime"),k0=a(()=>(0,gs.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,gs.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"#171717"})}),"TextBlockIcon"),Ln=a(({draggable:e=!1})=>(0,gs.jsx)(It,{draggable:e,icon:(0,gs.jsx)(k0,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var Pr=require("react/jsx-runtime"),rr=a(({type:e})=>{let t=(0,V1.useSetAtom)(ft);return(0,Pr.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,Pr.jsx)(Oe,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,Pr.jsx)(kl,{}),e==="text"&&(0,Pr.jsx)(Ln,{}),e==="image"&&(0,Pr.jsx)(Ml,{}),e==="spacer"&&(0,Pr.jsx)(Nl,{}),e==="divider"&&(0,Pr.jsx)(In,{}),e==="button"&&(0,Pr.jsx)(Sn,{}),e==="blockquote"&&(0,Pr.jsx)(B1,{}),e==="customCode"&&(0,Pr.jsx)(ds,{}),e==="column"&&(0,Pr.jsx)(Pl,{}),(0,Pr.jsx)(ye,{className:"courier-m-0"})]})},"FormHeader");var Rn=require("zod"),O1=Rn.z.object({paddingHorizontal:Rn.z.coerce.number().min(0),paddingVertical:Rn.z.coerce.number().min(0),backgroundColor:Rn.z.string(),borderLeftWidth:Rn.z.coerce.number().min(0),borderColor:Rn.z.string(),id:Rn.z.string().optional()});var xe=require("react/jsx-runtime"),z1=a(({element:e,editor:t})=>{let r=(0,U1.useForm)({resolver:(0,W1.zodResolver)(O1),defaultValues:{...cn,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,xe.jsxs)(et,{...r,children:[(0,xe.jsx)(rr,{type:"blockquote"}),(0,xe.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,xe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,xe.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,xe.jsx)(J,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,xe.jsxs)(Z,{children:[(0,xe.jsx)(q,{children:(0,xe.jsx)(pe,{startAdornment:(0,xe.jsx)(ri,{}),type:"number",min:0,...n})}),(0,xe.jsx)(K,{})]})}),(0,xe.jsx)(J,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,xe.jsxs)(Z,{children:[(0,xe.jsx)(q,{children:(0,xe.jsx)(pe,{startAdornment:(0,xe.jsx)(sn,{}),type:"number",min:0,...n})}),(0,xe.jsx)(K,{})]})})]}),(0,xe.jsx)(J,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,xe.jsxs)(Z,{className:"courier-mb-3",children:[(0,xe.jsx)(q,{children:(0,xe.jsx)(lt,{...n,defaultValue:cn.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,xe.jsx)(K,{})]})}),(0,xe.jsx)(ye,{className:"courier-mb-4"}),(0,xe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,xe.jsx)(J,{control:r.control,name:"borderLeftWidth",render:({field:n})=>(0,xe.jsxs)(Z,{className:"courier-mb-3",children:[(0,xe.jsx)(q,{children:(0,xe.jsx)(pe,{startAdornment:(0,xe.jsx)(zr,{}),type:"number",min:0,...n})}),(0,xe.jsx)(K,{})]})}),(0,xe.jsx)(J,{control:r.control,name:"borderColor",render:({field:n})=>(0,xe.jsxs)(Z,{className:"courier-mb-3",children:[(0,xe.jsx)(q,{children:(0,xe.jsx)(lt,{...n,defaultValue:cn.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,xe.jsx)(K,{})]})})]})]}):null},"BlockquoteForm");var or=require("zod"),Al=or.z.object({label:or.z.string(),link:or.z.string().optional(),alignment:or.z.enum(["left","center","right"]),size:or.z.enum(["default","full"]),backgroundColor:or.z.string(),textColor:or.z.string(),borderWidth:or.z.number(),borderRadius:or.z.number(),borderColor:or.z.string(),padding:or.z.number(),fontWeight:or.z.enum(["normal","bold"]),fontStyle:or.z.enum(["normal","italic"]),isUnderline:or.z.boolean(),isStrike:or.z.boolean()});var j1=require("@hookform/resolvers/zod"),Z1=require("react-hook-form");var Sl=require("jotai"),pi=Ae(require("react"),1),mi=require("react");var em=require("react/jsx-runtime"),hs=a(({items:e,command:t,selected:r=0})=>(0,em.jsx)("div",{className:"courier-bg-white courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto",children:e.map((o,n)=>(0,em.jsx)("button",{className:R("courier-w-full courier-px-4 courier-py-2 courier-text-left hover:courier-bg-gray-100 focus:courier-bg-gray-100 focus:courier-outline-none",n===r?"courier-bg-gray-100":""),onClick:()=>t(o),children:o},n))}),"VariableSuggestions");var jo=require("react/jsx-runtime"),kr=pi.forwardRef(({as:e="Input",variables:t=[],autoResize:r,onChange:o,...n},i)=>{let[s,l]=(0,mi.useState)(!1),[c,u]=(0,mi.useState)(null),[d,f]=(0,mi.useState)(0),m=(0,mi.useRef)(null),p=(0,mi.useRef)(null),v=(0,Sl.useSetAtom)(Xa),h=(0,Sl.useSetAtom)(Lf),g=(0,Sl.useSetAtom)(dl),C=pi.useCallback(()=>{if(!p.current)return;let k={ref:p.current,caretPosition:p.current.selectionStart};h(k),g(k);let w={isFocused:!0,hasVariables:t.length>0,showVariablePopup:!1};v(w)},[v,h,g,t]),P=pi.useCallback(k=>{var N,M;let w=k.relatedTarget&&((N=m.current)==null?void 0:N.contains(k.relatedTarget)),E=(M=k.relatedTarget)==null?void 0:M.closest("[data-variable-button]");!w&&!E&&(h({ref:null,caretPosition:null}),v({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[v,h]),y=a(k=>{let w=k.target,E={ref:w,caretPosition:w.selectionStart};h(E),g(E)},"handleSelect"),b=a(k=>{var w;if(s)switch(k.key){case"ArrowUp":k.preventDefault(),f(E=>E>0?E-1:t.length-1);break;case"ArrowDown":k.preventDefault(),f(E=>E<t.length-1?E+1:0);break;case"Enter":if(t[d]){k.preventDefault(),k.stopPropagation(),A(t[d]);return}break;case"Escape":l(!1),k.preventDefault(),k.stopPropagation();break}(w=n.onKeyDown)==null||w.call(n,k)},"handleKeyDown"),A=a(k=>{let w=p.current;if(!w)return;let E=w.value,N=w.selectionStart||0,M=E.substring(0,N-2),S=E.substring(N),D=`${M}{{${k}}}${S}`,L=N+k.length+3;if(o){let B={target:{...w,value:D}};o(B)}setTimeout(()=>{w.value=D,w.setSelectionRange(L,L)},0),l(!1)},"insertVariable"),x=a(k=>{var M;let w=k.target,E=w.value,N=w.selectionStart||0;if(E.slice(N-2,N)==="{{"&&((M=m.current)==null?void 0:M.getBoundingClientRect())){let D=E.slice(0,N),L=document.createElement("span");L.style.font=window.getComputedStyle(w).font,L.style.whiteSpace="pre-wrap",L.textContent=D,document.body.appendChild(L);let B=L.offsetWidth;document.body.removeChild(L);let V=parseInt(window.getComputedStyle(w).lineHeight),O=D.split(`
186
- `).length-1;u({left:Math.min(B%w.offsetWidth,w.offsetWidth-200),top:O*V+30}),l(!0),f(0)}o&&o({target:w,currentTarget:w,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleChange"),I=a(k=>{var M;let w=k.target,E=w.value,N=w.selectionStart||0;if(E.slice(N-2,N)==="{{"&&((M=m.current)==null?void 0:M.getBoundingClientRect())){let D=E.slice(0,N),L=document.createElement("span");L.style.font=window.getComputedStyle(w).font,L.style.whiteSpace="pre-wrap",L.textContent=D,document.body.appendChild(L);let B=L.offsetWidth;document.body.removeChild(L);let V=parseInt(window.getComputedStyle(w).lineHeight),O=D.split(`
187
- `).length-1;u({left:Math.min(B%w.offsetWidth,w.offsetWidth-200),top:O*V+30}),l(!0),f(0)}o&&o({target:w,currentTarget:w,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleInput");if(pi.useEffect(()=>{let k=p.current;if(!k)return;let w=a(E=>{u(E.detail.cursorPosition),l(!0),f(0)},"handleShowSuggestions");return k.addEventListener("showVariableSuggestions",w),()=>{k.removeEventListener("showVariableSuggestions",w)}},[]),e==="Input"){let k={...n,ref:w=>{p.current=w,typeof i=="function"?i(w):i&&(i.current=w)},onChange:x,onInput:I,onKeyDown:b,onFocus:C,onBlur:P,onSelect:y};return(0,jo.jsxs)("div",{ref:m,className:"courier-relative",children:[(0,jo.jsx)(pe,{...k}),s&&c&&(0,jo.jsx)("div",{style:{position:"absolute",left:`${c.left}px`,top:`${c.top}px`,zIndex:50},children:(0,jo.jsx)(hs,{items:t,command:A,selected:d})})]})}let T={...n,ref:k=>{p.current=k,typeof i=="function"?i(k):i&&(i.current=k)},onChange:x,onInput:I,onKeyDown:b,onFocus:C,onBlur:P,autoResize:r,onSelect:y};return(0,jo.jsxs)("div",{ref:m,className:"courier-relative",children:[(0,jo.jsx)(Ju,{...T}),s&&c&&(0,jo.jsx)("div",{style:{position:"absolute",left:`${c.left}px`,top:`${c.top}px`,zIndex:50},children:(0,jo.jsx)(hs,{items:t,command:A,selected:d})})]})});kr.displayName="TextInput";var Mr=require("react/jsx-runtime"),bs="#80849D",Zo=30,Il=a(({color:e=bs,width:t=Zo,height:r=Zo,...o})=>(0,Mr.jsx)(X,{...o,width:t,height:r,children:(0,Mr.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),Ll=a(({color:e=bs,width:t=Zo,height:r=Zo,...o})=>(0,Mr.jsx)(X,{...o,width:t,height:r,children:(0,Mr.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),Rl=a(({color:e=bs,width:t=Zo,height:r=Zo,...o})=>(0,Mr.jsx)(X,{...o,width:t,height:r,children:(0,Mr.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon"),_1=a(({color:e=bs,width:t=Zo,height:r=Zo,...o})=>(0,Mr.jsxs)(X,{...o,width:t,height:r,children:[(0,Mr.jsx)("path",{d:"M10.3007 18.8007C10.0566 19.0448 10.0566 19.4405 10.3007 19.6846C10.5448 19.9287 10.9405 19.9287 11.1846 19.6846L10.3007 18.8007ZM11.1846 10.3154C10.9405 10.0713 10.5448 10.0713 10.3007 10.3154C10.0566 10.5595 10.0566 10.9552 10.3007 11.1993L11.1846 10.3154ZM8.11464 14.375C7.76946 14.375 7.48964 14.6548 7.48964 15C7.48964 15.3452 7.76946 15.625 8.11464 15.625L8.11464 14.375ZM13.5092 15.625C13.8544 15.625 14.1342 15.3452 14.1342 15C14.1342 14.6548 13.8544 14.375 13.5092 14.375L13.5092 15.625ZM11.1846 19.6846L13.9512 16.918L13.0673 16.0341L10.3007 18.8007L11.1846 19.6846ZM13.9512 13.082L11.1846 10.3154L10.3007 11.1993L13.0673 13.9659L13.9512 13.082ZM13.9512 16.918C14.2866 16.5826 14.5836 16.2875 14.7889 16.0183C15.0053 15.7347 15.178 15.4078 15.178 15L13.928 15C13.928 15.0246 13.9267 15.0877 13.7951 15.2601C13.6526 15.4469 13.4277 15.6737 13.0673 16.0341L13.9512 16.918ZM13.0673 13.9659C13.4277 14.3263 13.6526 14.5531 13.7951 14.7399C13.9267 14.9123 13.928 14.9754 13.928 15L15.178 15C15.178 14.5922 15.0053 14.2653 14.7889 13.9817C14.5836 13.7125 14.2866 13.4174 13.9512 13.082L13.0673 13.9659ZM8.11464 15.625L13.5092 15.625L13.5092 14.375L8.11464 14.375L8.11464 15.625Z",fill:e}),(0,Mr.jsx)("path",{d:"M21.6993 18.8007C21.9434 19.0448 21.9434 19.4405 21.6993 19.6846C21.4552 19.9287 21.0595 19.9287 20.8154 19.6846L21.6993 18.8007ZM20.8154 10.3154C21.0595 10.0713 21.4552 10.0713 21.6993 10.3154C21.9434 10.5595 21.9434 10.9552 21.6993 11.1993L20.8154 10.3154ZM23.8854 14.375C24.2305 14.375 24.5104 14.6548 24.5104 15C24.5104 15.3452 24.2305 15.625 23.8854 15.625L23.8854 14.375ZM18.4908 15.625C18.1456 15.625 17.8658 15.3452 17.8658 15C17.8658 14.6548 18.1456 14.375 18.4908 14.375L18.4908 15.625ZM20.8154 19.6846L18.0488 16.918L18.9327 16.0341L21.6993 18.8007L20.8154 19.6846ZM18.0488 13.082L20.8154 10.3154L21.6993 11.1993L18.9327 13.9659L18.0488 13.082ZM18.0488 16.918C17.7134 16.5826 17.4164 16.2875 17.2111 16.0183C16.9947 15.7347 16.822 15.4078 16.822 15L18.072 15C18.072 15.0246 18.0733 15.0877 18.2049 15.2601C18.3474 15.4469 18.5723 15.6737 18.9327 16.0341L18.0488 16.918ZM18.9327 13.9659C18.5723 14.3263 18.3474 14.5531 18.2049 14.7399C18.0733 14.9123 18.072 14.9754 18.072 15L16.822 15C16.822 14.5922 16.9947 14.2653 17.2111 13.9817C17.4164 13.7125 17.7134 13.4174 18.0488 13.082L18.9327 13.9659ZM23.8854 15.625L18.4908 15.625L18.4908 14.375L23.8854 14.375L23.8854 15.625Z",fill:e})]}),"ButtonSizeDefaultIcon"),$1=a(({color:e=bs,width:t=Zo,height:r=Zo,...o})=>(0,Mr.jsxs)(X,{...o,width:t,height:r,children:[(0,Mr.jsx)("path",{d:"M9.18459 18.8007C9.42867 19.0448 9.42867 19.4405 9.18459 19.6846C8.94051 19.9287 8.54479 19.9287 8.30071 19.6846L9.18459 18.8007ZM8.30071 10.3154C8.54479 10.0713 8.94051 10.0713 9.18459 10.3154C9.42867 10.5595 9.42867 10.9552 9.18459 11.1993L8.30071 10.3154ZM11.3707 14.375C11.7158 14.375 11.9957 14.6548 11.9957 15C11.9957 15.3452 11.7158 15.625 11.3707 15.625L11.3707 14.375ZM5.97605 15.625C5.63087 15.625 5.35105 15.3452 5.35105 15C5.35105 14.6548 5.63087 14.375 5.97605 14.375L5.97605 15.625ZM8.30071 19.6846L5.5341 16.918L6.41799 16.0341L9.18459 18.8007L8.30071 19.6846ZM5.5341 13.082L8.30071 10.3154L9.18459 11.1993L6.41799 13.9659L5.5341 13.082ZM5.5341 16.918C5.19869 16.5826 4.90174 16.2875 4.69637 16.0183C4.48 15.7347 4.30733 15.4078 4.30733 15L5.55733 15C5.55733 15.0246 5.55861 15.0877 5.69015 15.2601C5.83269 15.4469 6.05759 15.6737 6.41799 16.0341L5.5341 16.918ZM6.41799 13.9659C6.05759 14.3263 5.83269 14.5531 5.69015 14.7399C5.55861 14.9123 5.55733 14.9754 5.55733 15L4.30733 15C4.30733 14.5922 4.48 14.2653 4.69637 13.9817C4.90174 13.7125 5.19869 13.4174 5.5341 13.082L6.41799 13.9659ZM11.3707 15.625L5.97605 15.625L5.97605 14.375L11.3707 14.375L11.3707 15.625Z",fill:e}),(0,Mr.jsx)("path",{d:"M22.8154 18.8007C22.5713 19.0448 22.5713 19.4405 22.8154 19.6846C23.0595 19.9287 23.4552 19.9287 23.6993 19.6846L22.8154 18.8007ZM23.6993 10.3154C23.4552 10.0713 23.0595 10.0713 22.8154 10.3154C22.5713 10.5595 22.5713 10.9552 22.8154 11.1993L23.6993 10.3154ZM20.6293 14.375C20.2842 14.375 20.0043 14.6548 20.0043 15C20.0043 15.3452 20.2842 15.625 20.6293 15.625L20.6293 14.375ZM26.024 15.625C26.3691 15.625 26.649 15.3452 26.649 15C26.649 14.6548 26.3691 14.375 26.024 14.375L26.024 15.625ZM23.6993 19.6846L26.4659 16.918L25.582 16.0341L22.8154 18.8007L23.6993 19.6846ZM26.4659 13.082L23.6993 10.3154L22.8154 11.1993L25.582 13.9659L26.4659 13.082ZM26.4659 16.918C26.8013 16.5826 27.0983 16.2875 27.3036 16.0183C27.52 15.7347 27.6927 15.4078 27.6927 15L26.4427 15C26.4427 15.0246 26.4414 15.0877 26.3099 15.2601C26.1673 15.4469 25.9424 15.6737 25.582 16.0341L26.4659 16.918ZM25.582 13.9659C25.9424 14.3263 26.1673 14.5531 26.3099 14.7399C26.4414 14.9123 26.4427 14.9754 26.4427 15L27.6927 15C27.6927 14.5922 27.52 14.2653 27.3036 13.9817C27.0983 13.7125 26.8013 13.4174 26.4659 13.082L25.582 13.9659ZM20.6293 15.625L26.024 15.625L26.024 14.375L20.6293 14.375L20.6293 15.625Z",fill:e})]}),"ButtonSizeFullIcon");var $=require("react/jsx-runtime"),q1=a(({element:e,editor:t})=>{let r=(0,Z1.useForm)({resolver:(0,j1.zodResolver)(Al),defaultValues:{...$e,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,$.jsxs)(et,{...r,children:[(0,$.jsx)(rr,{type:"button"}),(0,$.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,$.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,$.jsx)(J,{control:r.control,name:"link",render:({field:n})=>(0,$.jsxs)(Z,{children:[(0,$.jsx)(q,{children:(0,$.jsx)(kr,{as:"Textarea",...n,variables:[],onChange:i=>{n.onChange(i),o({...r.getValues(),link:i.target.value})}})}),(0,$.jsx)(K,{})]})}),(0,$.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,$.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Color"}),(0,$.jsx)(J,{control:r.control,name:"textColor",render:({field:n})=>(0,$.jsxs)(Z,{className:"courier-mb-4",children:[(0,$.jsx)(q,{children:(0,$.jsx)(lt,{...n,defaultValue:$e.textColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,$.jsx)(K,{})]})}),(0,$.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,$.jsx)(J,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,$.jsxs)(Z,{className:"courier-mb-4",children:[(0,$.jsx)(q,{children:(0,$.jsx)(lt,{...n,defaultValue:$e.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,$.jsx)(K,{})]})}),(0,$.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,$.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,$.jsx)(J,{control:r.control,name:"padding",render:({field:n})=>(0,$.jsxs)(Z,{className:"courier-mb-2",children:[(0,$.jsx)(q,{children:(0,$.jsx)(pe,{type:"number",min:0,...n})}),(0,$.jsx)(K,{})]})}),(0,$.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6",children:[(0,$.jsx)(J,{control:r.control,name:"alignment",render:({field:n})=>(0,$.jsxs)(Z,{children:[(0,$.jsx)(q,{children:(0,$.jsxs)(er,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},children:[(0,$.jsx)(tt,{value:"left",children:(0,$.jsx)(Il,{})}),(0,$.jsx)(tt,{value:"center",children:(0,$.jsx)(Ll,{})}),(0,$.jsx)(tt,{value:"right",children:(0,$.jsx)(Rl,{})})]})}),(0,$.jsx)(K,{})]})}),(0,$.jsx)(J,{control:r.control,name:"size",render:({field:n})=>(0,$.jsxs)(Z,{children:[(0,$.jsx)(q,{children:(0,$.jsxs)(er,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),size:i})},children:[(0,$.jsx)(tt,{value:"default",children:(0,$.jsx)(_1,{})}),(0,$.jsx)(tt,{value:"full",children:(0,$.jsx)($1,{})})]})}),(0,$.jsx)(K,{})]})})]}),(0,$.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,$.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,$.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,$.jsx)(J,{control:r.control,name:"borderWidth",render:({field:n})=>(0,$.jsxs)(Z,{children:[(0,$.jsx)(q,{children:(0,$.jsx)(pe,{startAdornment:(0,$.jsx)(zr,{}),type:"number",min:0,...n})}),(0,$.jsx)(K,{})]})}),(0,$.jsx)(J,{control:r.control,name:"borderRadius",render:({field:n})=>(0,$.jsxs)(Z,{children:[(0,$.jsx)(q,{children:(0,$.jsx)(pe,{startAdornment:(0,$.jsx)(an,{}),type:"number",min:0,...n})}),(0,$.jsx)(K,{})]})})]}),(0,$.jsx)(J,{control:r.control,name:"borderColor",render:({field:n})=>(0,$.jsxs)(Z,{className:"courier-mb-4",children:[(0,$.jsx)(q,{children:(0,$.jsx)(lt,{...n,defaultValue:$e.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,$.jsx)(K,{})]})})]})]}):null},"ButtonForm");var Fl=require("@tiptap/core"),K1=require("@tiptap/react"),Y1=require("uuid");var Bl=require("jotai"),je=require("react");var ys=require("react/jsx-runtime"),Hl=a(({color:e="#1D4ED8"})=>(0,ys.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,ys.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,ys.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var _t=require("react/jsx-runtime"),M0=a(e=>{if(!e)return[];let t=[],r=/\{\{([^}]+)\}\}/g,o=0,n;for(r.lastIndex=0;(n=r.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;n.index>o&&t.push({type:"text",content:e.substring(o,n.index)});let i=n[1].trim();ur(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),N0=a(({parts:e})=>{let t=(0,Bl.useAtomValue)(Xn);return(0,_t.jsx)(_t.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,_t.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,_t.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,_t.jsx)(Hl,{color:n?void 0:"#B45309"}),(0,_t.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),J1=a(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,je.useRef)(null),s=(0,je.useRef)(e),l=(0,je.useRef)(!1),[c,u]=(0,je.useState)(!1),d=M0(e),m=d.some(x=>x.type==="variable")&&!c;(0,je.useLayoutEffect)(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(I=>I.nodeType===Node.TEXT_NODE).forEach(I=>I.remove())},[m,e]);let p=(0,je.useRef)(m),v=(0,je.useRef)(!0);(0,je.useEffect)(()=>{if(!i.current||m){p.current=m;return}let x=p.current&&!m;p.current=m,(v.current||x||!l.current&&e!==s.current)&&(i.current.textContent=e),v.current=!1,s.current=e},[e,m]);let h=(0,je.useCallback)(()=>{if(i.current&&!m){l.current=!0;let x=i.current.textContent||"";s.current=x,o(x),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),g=(0,je.useCallback)(x=>{var I;if(m){x.preventDefault(),x.stopPropagation();return}if(x.key==="Enter"&&(x.preventDefault(),(I=i.current)==null||I.blur()),(x.metaKey||x.ctrlKey)&&x.key==="a"&&(x.preventDefault(),x.stopPropagation(),i.current)){let T=document.createRange();T.selectNodeContents(i.current);let k=window.getSelection();k==null||k.removeAllRanges(),k==null||k.addRange(T)}},[m]),C=(0,je.useCallback)(()=>{u(!0)},[]),P=(0,je.useCallback)(()=>{u(!1)},[]),y=(0,je.useCallback)(x=>{let I=i.current;if(!I)return;if(m&&n){x.stopPropagation(),setTimeout(()=>{I.focus();let w=document.createRange();w.selectNodeContents(I),w.collapse(!1);let E=window.getSelection();E==null||E.removeAllRanges(),E==null||E.addRange(w)},0);return}if(!n)return;let T=a(()=>{let w=window.getSelection();if(!w||w.rangeCount===0)return;let E=w.getRangeAt(0),N=I.contains(E.startContainer),M=I.contains(E.endContainer);if(N&&!M){let S=document.createRange();S.selectNodeContents(I),w.removeAllRanges(),w.addRange(S)}},"checkAndConstrainSelection"),k=a(w=>{let E=I.getBoundingClientRect();(w.clientX<E.left||w.clientX>E.right||w.clientY<E.top||w.clientY>E.bottom)&&T(),document.removeEventListener("mouseup",k)},"handleMouseUp");document.addEventListener("mouseup",k)},[n,m]),b=m?(0,_t.jsx)(N0,{parts:d}):n?null:e,A=(0,je.useCallback)(x=>{m&&n&&x.stopPropagation()},[m,n]);return(0,_t.jsx)("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:g,onPointerDown:y,onClick:A,onFocus:C,onBlur:P,className:R("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"#000000",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:b})},"EditableButton"),A0=a(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:s,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:f=!1})=>(0,_t.jsx)("div",{className:"node-element",children:(0,_t.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,_t.jsx)(J1,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:f},"button1"),(0,_t.jsx)(J1,{label:n,backgroundColor:s,textColor:l,onLabelChange:d||(()=>{}),editable:f},"button2")]})}),"ButtonRowComponent"),G1=a(e=>{let t=(0,Bl.useSetAtom)(ft),r=(0,je.useRef)({}),o=(0,je.useRef)({}),n=(0,je.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Lt(e);l&&t(l)},[e,t]),i=(0,je.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),s=(0,je.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,je.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,_t.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,_t.jsx)(A0,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:s,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var xo={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},Vl=Fl.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){St(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Y1.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:xo.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:xo.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:xo.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:xo.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:xo.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:xo.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:xo.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:xo.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:xo.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Fl.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,K1.ReactNodeViewRenderer)(G1,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...xo,...e}}).run()}}});var Wl=require("@tiptap/core"),eg=require("@tiptap/react"),tg=require("uuid");var X1=require("@tiptap/react"),Ol=require("jotai"),jr=require("react");var To=require("react/jsx-runtime"),S0=a(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,jr.useRef)(null),[n,i]=(0,jr.useState)(!1);return(0,jr.useEffect)(()=>{let s=o.current;if(s)return _r({element:s,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,To.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:s=>{s.stopPropagation()},className:R("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,To.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),I0=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:s,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!s.content||s.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},f={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let p=((m=s.attrs)==null?void 0:m.id)||"";return(0,To.jsx)("div",{className:"courier-w-full node-element",style:f,children:(0,To.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>(0,To.jsx)(S0,{columnId:p,index:h,isPreviewMode:c},h))})})}return(0,To.jsx)("div",{className:"courier-w-full node-element",style:f,children:(0,To.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,To.jsx)(X1.NodeViewContent,{})})})},"ColumnComponent"),Q1=a(e=>{let t=(0,Ol.useSetAtom)(ft),r=(0,Ol.useAtomValue)(Cr),[o,n]=(0,jr.useState)(!1),[i,s]=(0,jr.useState)(e.editor.isEditable);(0,jr.useEffect)(()=>{let f=a(()=>{s(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",f),e.editor.on("transaction",f),e.editor.on("selectionUpdate",f),()=>{e.editor.off("update",f),e.editor.off("transaction",f),e.editor.off("selectionUpdate",f)}},[e.editor]);let l=!i&&!r,c=(0,jr.useCallback)(f=>{var A,x;if(!e.editor.isEditable)return;let m=f.target,p=f.currentTarget,v=m===p,h=m.classList.contains("node-element"),g=m.classList.contains("courier-p-2"),C=m.classList.contains("courier-gap-2"),P=m.classList.contains("draggable-item"),y=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(v||h||g||C||P||y||((x=(A=m.closest("[data-node-view-content]"))==null?void 0:A.parentElement)==null?void 0:x.classList.contains("node-element"))){f.stopPropagation(),y||f.preventDefault();let I=Lt(e);if(I){e.editor.commands.blur();let T=I.attrs.id;e.editor.state.doc.descendants(k=>k.type.name==="column"&&k.attrs.id===T?(t(k),!1):!0)}}},[e,t]),u=(0,jr.useCallback)(f=>{let m=f.target,p=f.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let h=p.getBoundingClientRect(),g=f.clientY,C=30,P=g<=h.top+C||g>=h.bottom-C;n(P)},[]),d=(0,jr.useCallback)(()=>{n(!1)},[]);return(0,To.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,To.jsx)(I0,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var $t={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"#000000",cells:[]},Ul=Wl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){St(this.editor,this.name)},addAttributes(){return{columnsCount:{default:$t.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:$t.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:$t.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:$t.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:$t.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:$t.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:$t.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,tg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Wl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,eg.ReactNodeViewRenderer)(Q1)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||$t.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,s)=>({type:"columnCell",attrs:{index:s,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var og=require("@hookform/resolvers/zod"),ng=require("react-hook-form");var Zr=require("zod"),rg=Zr.z.object({columnsCount:Zr.z.number().min(1).max(4).default(2),paddingHorizontal:Zr.z.number().default(0),paddingVertical:Zr.z.number().default(0),backgroundColor:Zr.z.string().default("transparent"),borderWidth:Zr.z.number().default(0),borderRadius:Zr.z.number().default(0),borderColor:Zr.z.string().default("#000000"),cells:Zr.z.array(Zr.z.object({elements:Zr.z.array(Zr.z.any())})).optional()});var te=require("react/jsx-runtime"),tm=a(({element:e,editor:t})=>{let r=(0,ng.useForm)({resolver:(0,og.zodResolver)(rg),defaultValues:{...$t,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"column"}),n=a(i=>{if(!t||!e)return;let s=null;if(t.state.doc.descendants((p,v)=>p.attrs.id===e.attrs.id&&p.type.name==="column"?(s=v,!1):!0),s===null)return;let l=t.state.doc.nodeAt(s);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,f=l.firstChild;if(!f||f.type.name!=="columnRow"){let p=Array.from({length:i},(h,g)=>u.nodes.columnCell.create({index:g,columnId:c,isEditorMode:!1})),v=u.nodes.columnRow.create({},p);d.replaceWith(s+1,s+l.nodeSize-1,v),d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let m=f.childCount;if(i!==m){if(i>m){let p=i-m,h=s+1+f.nodeSize-1;for(let g=0;g<p;g++){let C=u.nodes.columnCell.create({index:m+g,columnId:c});d.insert(h+g*C.nodeSize,C)}}else{let p=m-i,h=s+1;for(let C=0;C<m-p;C++){let P=f.child(C);h+=P.nodeSize}let g=0;for(let C=m-p;C<m;C++){let P=f.child(C);g+=P.nodeSize}d.delete(h,h+g)}d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,te.jsxs)(et,{...r,children:[(0,te.jsx)(rr,{type:"column",label:"Column layout"}),(0,te.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Columns count"}),(0,te.jsx)(J,{control:r.control,name:"columnsCount",render:({field:i})=>(0,te.jsxs)(Z,{className:"courier-mb-4",children:[(0,te.jsx)(q,{children:(0,te.jsx)(er,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:s=>{if(s){let l=Number(s);i.onChange(l),n(l)}},children:[1,2,3,4].map(s=>(0,te.jsx)(tt,{value:s.toString(),className:"courier-w-12 courier-h-7",children:(0,te.jsx)("span",{className:"courier-text-sm courier-font-medium",children:s})},s))})}),(0,te.jsx)(K,{})]})}),(0,te.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,te.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,te.jsx)(J,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,te.jsxs)(Z,{children:[(0,te.jsx)(q,{children:(0,te.jsx)(pe,{startAdornment:(0,te.jsx)(ri,{}),type:"number",min:0,...i})}),(0,te.jsx)(K,{})]})}),(0,te.jsx)(J,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,te.jsxs)(Z,{children:[(0,te.jsx)(q,{children:(0,te.jsx)(pe,{startAdornment:(0,te.jsx)(sn,{}),type:"number",min:0,...i})}),(0,te.jsx)(K,{})]})})]}),(0,te.jsx)(J,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,te.jsxs)(Z,{className:"courier-mb-4",children:[(0,te.jsx)(q,{children:(0,te.jsx)(lt,{...i,defaultValue:$t.backgroundColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,te.jsx)(K,{})]})}),(0,te.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,te.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,te.jsx)(J,{control:r.control,name:"borderWidth",render:({field:i})=>(0,te.jsxs)(Z,{children:[(0,te.jsx)(q,{children:(0,te.jsx)(pe,{startAdornment:(0,te.jsx)(zr,{}),type:"number",min:0,...i})}),(0,te.jsx)(K,{})]})}),(0,te.jsx)(J,{control:r.control,name:"borderRadius",render:({field:i})=>(0,te.jsxs)(Z,{children:[(0,te.jsx)(q,{children:(0,te.jsx)(pe,{startAdornment:(0,te.jsx)(an,{}),type:"number",min:0,...i})}),(0,te.jsx)(K,{})]})})]}),(0,te.jsx)(J,{control:r.control,name:"borderColor",render:({field:i})=>(0,te.jsxs)(Z,{className:"courier-mb-4",children:[(0,te.jsx)(q,{children:(0,te.jsx)(lt,{...i,defaultValue:$t.borderColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,te.jsx)(K,{})]})})]})]}):null},"ColumnForm");var zl=require("@tiptap/core"),_l=zl.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,zl.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var jl=require("@tiptap/core"),sg=require("@tiptap/react"),Zl=require("@tiptap/pm/state");var $l=require("@tiptap/react"),Dn=require("react");var ig=require("jotai");var vs=require("react/jsx-runtime"),ag=a(e=>{let t=(0,Dn.useRef)(null),[r,o]=(0,Dn.useState)(!1),n=(0,ig.useAtomValue)(Cr),i=e.node.attrs.isEditorMode===!0,[s,l]=(0,Dn.useState)(e.editor.isEditable);(0,Dn.useEffect)(()=>{let d=t.current;if(d)return _r({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Dn.useEffect)(()=>{let d=a(()=>{l(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",d),e.editor.on("transaction",d),e.editor.on("selectionUpdate",d),()=>{e.editor.off("update",d),e.editor.off("transaction",d),e.editor.off("selectionUpdate",d)}},[e.editor]);let c=!s&&!n,u=!i&&!c;return(0,vs.jsxs)($l.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:R("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,vs.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,vs.jsx)($l.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var ql=jl.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,jl.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,sg.ReactNodeViewRenderer)(ag)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Zl.Plugin({key:new Zl.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,s)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,f=i.attrs.isEditorMode;u?f=!1:u||(f=!0),f!==i.attrs.isEditorMode&&(o.setNodeAttribute(s,"isEditorMode",f),n=!0),d&&f===!1&&(o.delete(s+1,s+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var Jl=require("@tiptap/core"),dg=require("@tiptap/react"),mg=require("uuid");var lg=require("jotai"),cg=require("react");var Cs=require("react/jsx-runtime"),L0=a(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,Cs.jsx)("div",{className:"courier-w-full node-element",children:(0,Cs.jsx)("div",{className:"courier-custom-code courier-py-1.5 courier-overflow-auto",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),ug=a(e=>{let t=(0,lg.useSetAtom)(ft),r=(0,cg.useCallback)(()=>{if(!e.editor.isEditable)return;let i=Lt(e);if(i){e.editor.commands.blur();let s=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===s?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,Cs.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,Cs.jsx)(L0,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var un={code:"<!-- Add your HTML code here -->"},Gl=Jl.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){St(this.editor,this.name)},addAttributes(){return{code:{default:un.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,mg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Jl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||un.code}]]},addNodeView(){return(0,dg.ReactNodeViewRenderer)(ug)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var qr=require("react");var pg=require("react"),fg=require("react/jsx-runtime"),rm=(0,pg.forwardRef)(({className:e,...t},r)=>{let o=R("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,fg.jsx)("div",{className:o,ref:r,...t})});rm.displayName="Spinner";var fi=require("react/jsx-runtime"),R0=(0,qr.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function D0(e,t){let r=(0,qr.useRef)();return(0,qr.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}a(D0,"useDebounce");var H0=a((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(s=>s.severity===8).length>0)return!1;if(!e.trim())return!0;try{if(/<[a-z][a-z0-9]*\s[^>]*$/i.test(e.trim()))return!1;let l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(g=>{var C,P;return(P=(C=g.match(/<([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:P.toLowerCase()}).filter(Boolean),p=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(g=>{var C,P;return(P=(C=g.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:P.toLowerCase()}).filter(Boolean),v=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(g=>g&&!v.includes(g));for(let g of h){let C=m.filter(y=>y===g).length,P=p.filter(y=>y===g).length;if(C!==P)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),Kl=a(({code:e,onSave:t,onValidationChange:r,validator:o=H0})=>{let n=(0,qr.useRef)(null),i=(0,qr.useRef)(null),[s,l]=(0,qr.useState)(!0),c=(0,qr.useCallback)(()=>{if(!n.current||!i.current)return!0;let m=n.current.getModel();if(!m)return!0;let p=m.getValue(),v=o(p,n.current,i.current);return v!==s&&(l(v),r==null||r(v)),v},[s,r,o]),u=D0(m=>{setTimeout(()=>{c()&&t(m)},150)},500);return(0,fi.jsx)("div",{className:"courier-h-full courier-overflow-hidden",children:(0,fi.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,fi.jsx)(qr.Suspense,{fallback:(0,fi.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,fi.jsx)(rm,{})}),children:(0,fi.jsx)(R0,{height:"100%",defaultLanguage:"html",value:e,onChange:a(m=>{u(m||"")},"handleCodeChange"),onMount:a((m,p)=>{n.current=m,i.current=p,m.focus(),m.onDidChangeModelContent(()=>{setTimeout(c,100)}),setTimeout(c,100)},"handleEditorDidMount"),theme:"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var hg=require("@hookform/resolvers/zod"),bg=require("react-hook-form");var om=require("zod"),gg=om.z.object({code:om.z.string()});var yg=require("react"),vg=require("jotai");var gt=require("react/jsx-runtime"),nm=a(({element:e,editor:t})=>{let r=(0,bg.useForm)({resolver:(0,hg.zodResolver)(gg),defaultValues:{...un,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,vg.useAtom)(Wo),s=(0,yg.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,gt.jsxs)(et,{...r,children:[!n&&(0,gt.jsx)(rr,{type:"customCode"}),(0,gt.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,gt.jsx)(Oe,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(kd,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(Ua,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,gt.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,gt.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,gt.jsx)(J,{control:r.control,name:"code",render:({field:l})=>(0,gt.jsxs)(Z,{className:"courier-h-full",children:[(0,gt.jsx)(q,{children:(0,gt.jsx)(Kl,{code:l.value,onSave:c=>{l.onChange(c),s(c)},onCancel:()=>{}})}),(0,gt.jsx)(K,{})]})})})})]})]}):null},"CustomCodeForm");var Eg=require("@tiptap/core");var Hn=require("@tiptap/core"),la=require("@tiptap/pm/state"),Cg=Hn.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,Hn.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,Hn.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:l})=>{var c;if(l){let{$to:u}=s.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?s.setSelection(la.TextSelection.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(la.NodeSelection.create(s.doc,u.pos)):s.setSelection(la.TextSelection.create(s.doc,u.pos));else{let f=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();f&&(s.insert(d,f),s.setSelection(la.TextSelection.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,Hn.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Pg=require("@tiptap/react"),kg=require("uuid");var xg=require("jotai"),Tg=require("react");var xs=require("react/jsx-runtime"),B0=a(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,xs.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,xs.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),wg=a(e=>{let t=(0,xg.useSetAtom)(ft),r=(0,Tg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=Lt(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,xs.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,xs.jsx)(B0,{...e.node.attrs})})},"DividerComponentNode");var Jr={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},Yl={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},im=Cg.extend({name:"divider",atom:!0,onCreate(){St(this.editor,this.name)},addAttributes(){return{padding:{default:Jr.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:Jr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:Jr.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:Jr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:Jr.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:Jr.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,kg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Eg.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,Pg.ReactNodeViewRenderer)(wg)}});var gi=require("zod"),Mg=gi.z.object({padding:gi.z.number(),color:gi.z.string(),size:gi.z.number(),radius:gi.z.number(),variant:gi.z.enum(["divider","spacer"]).default("divider")});var Ng=require("@hookform/resolvers/zod"),Ag=require("react-hook-form");var Fe=require("react/jsx-runtime"),Sg=a(({element:e,editor:t})=>{let r=(0,Ag.useForm)({resolver:(0,Ng.zodResolver)(Mg),defaultValues:{...Jr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,Fe.jsxs)(et,{...r,children:[(0,Fe.jsx)(rr,{type:n}),(0,Fe.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Fe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Fe.jsx)(J,{control:r.control,name:"padding",render:({field:i})=>(0,Fe.jsxs)(Z,{children:[(0,Fe.jsx)(q,{children:(0,Fe.jsx)(pe,{startAdornment:(0,Fe.jsx)(sn,{}),type:"number",...i,onChange:s=>{i.onChange(s),o({...r.getValues(),margin:s.target.value})}})}),(0,Fe.jsx)(K,{})]})}),n==="divider"&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,Fe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,Fe.jsx)(J,{control:r.control,name:"size",render:({field:i})=>(0,Fe.jsxs)(Z,{className:"courier-mb-4",children:[(0,Fe.jsx)(q,{children:(0,Fe.jsx)(pe,{startAdornment:(0,Fe.jsx)(zr,{}),type:"number",min:0,...i,onChange:s=>{i.onChange(s),o({...r.getValues(),width:s.target.value})}})}),(0,Fe.jsx)(K,{})]})}),(0,Fe.jsx)(J,{control:r.control,name:"color",render:({field:i})=>(0,Fe.jsxs)(Z,{className:"courier-mb-4",children:[(0,Fe.jsx)(q,{children:(0,Fe.jsx)(lt,{...i,defaultValue:Jr.color,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,Fe.jsx)(K,{})]})})]})]})]})},"DividerForm");var Ig=require("@tiptap/core"),Lg=Ig.Node.create({name:"doc",topNode:!0,content:"block+"});var am=Lg.extend({content:"(block)+"});var Hg=require("@tiptap/core"),Bg=require("@tiptap/react");var Rg=require("@tiptap/react"),hi=require("react");var Ts=require("react/jsx-runtime");function F0(){let[e,t]=(0,hi.useState)(!1);return(0,hi.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(F0,"useMountStatus");var V0=(0,hi.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,hi.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Ts.jsx)(Rg.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:R("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),O0=a(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),Dg=a(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=F0();return(0,Ts.jsx)(V0,{id:r,fadeIn:!o,children:(0,Ts.jsx)("div",{className:R("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,Ts.jsx)("div",{className:"courier-text-accent-foreground",children:O0(t)})})})},"DragPlaceholderComponent");var Fg=Hg.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,Bg.ReactNodeViewRenderer)(Dg,{as:"div",className:"drag-placeholder-wrapper"})}});var Vg=require("@tiptap/core"),Xl=require("@tiptap/pm/state"),W0=new Xl.PluginKey("file-handler"),U0=Vg.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new Xl.Plugin({key:W0,props:{handleDrop:(o,n,i,s)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||s)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(f=>e==null?void 0:e.includes(f.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,s=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return s.length===0?!1:(n.preventDefault(),r&&r(this.editor,s),!0)}}})]}}),Ql=U0;var Og=require("@tiptap/core"),ec=require("@tiptap/pm/state");var z0=new ec.PluginKey("fixedChannelPaste"),_0=a(e=>{let t=e.view.dom.closest(".courier-push-editor"),r=e.view.dom.closest(".courier-sms-editor"),o=e.view.dom.closest(".courier-inbox-editor");if(t||r||o)return!0;let n=e.state.doc,i=0,s=0;n.forEach(d=>{d.type.name==="paragraph"||d.type.name==="heading"?i++:d.type.name==="button"&&s++});let l=i===1&&s===0,c=i===2&&s===0,u=i>=2&&i+s<=4;return l||c||u},"isInFixedChannel"),$0=a(e=>{let t=[],r=a(o=>{if(o.type.name==="text")t.push(o.text||"");else if(o.type.name==="paragraph"||o.type.name==="heading"){let n=o.textContent||"";n.trim()&&t.push(n)}else o.content&&o.content.forEach(n=>{r(n)})},"extractTextFromNode");return e.content.forEach(o=>{r(o)}),t.filter(o=>o.trim()).join(`
188
- `).trim()},"extractTextFromSlice"),tc=Og.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new ec.Plugin({key:z0,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!_0(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading")||o.content.childCount<=1)return!1;let u=$0(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var Ug=require("@tiptap/core"),Bn=require("@tiptap/pm/state");var bi=a((e,t)=>{if(t.length===0)return!1;let r={push:()=>e.view.dom.closest(".courier-push-editor"),sms:()=>e.view.dom.closest(".courier-sms-editor"),inbox:()=>e.view.dom.closest(".courier-inbox-editor")};return t.some(o=>{var n;return(n=r[o])==null?void 0:n.call(r)})},"isInFixedChannel"),sm=a(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Wg=a(e=>{if(!sm(e))return!1;let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.node(o-1),s=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===s)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),yi=a(e=>{let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),s=r.end(o);return{start:i,end:s,node:n}}o--}return null},"getCurrentElementBounds"),rc=a(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,s=null,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){s={node:c,depth:n};break}n--}for(;i>0;){let c=o.node(i);if(c.type.name==="paragraph"||c.type.name==="heading"){l={node:c,depth:i};break}i--}return!!(s&&l&&s.node!==l.node)},"isMultiElementSelection"),oc=new Bn.PluginKey("fixedChannelSelection"),nc=Ug.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!bi(e,this.options.channels))return!1;let o=yi(e);if(!o)return!1;let{start:n,end:i}=o,{selection:s}=e.state;if(s.from>=n&&s.to<=i)return!1;let l=Math.max(s.from,n),c=Math.min(s.to,i);return r&&t.setSelection(Bn.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!bi(e,this.options.channels))return!1;let t=yi(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!bi(e,this.options.channels))return!1;if(sm(e)){let{selection:t}=e.state;if(yi(e)&&t.$anchor.parentOffset===0&&Wg(e))return!0}if(rc(e)){let t=yi(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1},Delete:({editor:e})=>{if(!bi(e,this.options.channels))return!1;if(sm(e)){let{selection:t}=e.state,r=yi(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Wg(e))return!0}}if(rc(e)){let t=yi(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1}}},addProseMirrorPlugins(){return[new Bn.Plugin({key:oc,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!bi(o,this.options.channels))return!1;if(rc(o)){let n=yi(o);if(n){let{start:i,end:s}=n,l=Math.max(t,i),c=Math.min(r,s),u=e.state.tr;u.setSelection(Bn.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!bi(r,this.options.channels))return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY});if(o!==null){let n=e.state.doc.resolve(o.pos),i=n.depth;for(;i>0;){let s=n.node(i);if(s.type.name==="paragraph"||s.type.name==="heading"){e.dispatch(e.state.tr.setMeta(oc,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!bi(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&rc(r)){let n=oc.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,s=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(Bn.TextSelection.create(c.doc,s,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(oc)||t}}})]}});var Gg=require("@tiptap/core");var ca=require("@tiptap/core"),zg=ca.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,ca.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,ca.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var oo=require("zod"),_g=oo.z.object({paddingVertical:oo.z.number(),paddingHorizontal:oo.z.number(),backgroundColor:oo.z.string(),borderWidth:oo.z.number(),borderRadius:oo.z.number(),borderColor:oo.z.string(),textColor:oo.z.string(),textAlign:oo.z.enum(["left","center","right","justify"]).default("left"),selected:oo.z.boolean().default(!1),id:oo.z.string().optional()}),de={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"#000000",textColor:"#292929",textAlign:"left",selected:!1};var ic=require("@tiptap/react"),ac=require("jotai"),jg=require("react");var dn=require("react/jsx-runtime"),$g=a(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderRadius:i,borderColor:s,textColor:l,level:c,type:u})=>{let d=u==="heading"?`h${c}`:"p",f=(0,ac.useAtomValue)(Cr);return(0,dn.jsx)("div",{className:"courier-w-full node-element",children:(0,dn.jsx)("div",{className:R(!l&&"is-empty"),style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderRadius:`${i}px`,borderColor:s,borderStyle:n>0?"solid":"none",color:l},children:(0,dn.jsx)("div",{style:{pointerEvents:f?"none":"auto"},children:(0,dn.jsx)(ic.NodeViewContent,{as:d})})})})},"TextBlockComponent"),sc=a(e=>{let t=(0,ac.useSetAtom)(ft),r=(0,jg.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Lt(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=Fn(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,dn.jsx)(ic.NodeViewWrapper,{children:(0,dn.jsx)($g,{...e.node.attrs,type:e.node.type.name})}):(0,dn.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,dn.jsx)($g,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var Zg=require("@hookform/resolvers/zod"),qg=require("react-hook-form");var ne=require("react/jsx-runtime"),Jg=a(({element:e,editor:t})=>{let r=(0,qg.useForm)({resolver:(0,Zg.zodResolver)(_g),defaultValues:{...de,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,ne.jsxs)(et,{...r,children:[(0,ne.jsx)(rr,{type:"text"}),(0,ne.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ne.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ne.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ne.jsx)(J,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,ne.jsxs)(Z,{children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(pe,{startAdornment:(0,ne.jsx)(ri,{}),type:"number",min:0,...n})}),(0,ne.jsx)(K,{})]})}),(0,ne.jsx)(J,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,ne.jsxs)(Z,{children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(pe,{startAdornment:(0,ne.jsx)(sn,{}),type:"number",min:0,...n})}),(0,ne.jsx)(K,{})]})})]}),(0,ne.jsx)(J,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ne.jsxs)(Z,{className:"courier-mb-4",children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(lt,{...n,defaultValue:de.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ne.jsx)(K,{})]})}),(0,ne.jsx)(ye,{className:"courier-mb-4"}),(0,ne.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Text"}),(0,ne.jsx)(J,{control:r.control,name:"textColor",render:({field:n})=>(0,ne.jsxs)(Z,{className:"courier-mb-4",children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(lt,{...n,transparent:!1,defaultValue:de.textColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ne.jsx)(K,{})]})}),(0,ne.jsx)(ye,{className:"courier-mb-4"}),(0,ne.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ne.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ne.jsx)(J,{control:r.control,name:"borderWidth",render:({field:n})=>(0,ne.jsxs)(Z,{children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(pe,{startAdornment:(0,ne.jsx)(zr,{}),type:"number",min:0,...n})}),(0,ne.jsx)(K,{})]})}),(0,ne.jsx)(J,{control:r.control,name:"borderRadius",render:({field:n})=>(0,ne.jsxs)(Z,{children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(pe,{startAdornment:(0,ne.jsx)(an,{}),type:"number",min:0,...n})}),(0,ne.jsx)(K,{})]})})]}),(0,ne.jsx)(J,{control:r.control,name:"borderColor",render:({field:n})=>(0,ne.jsxs)(Z,{className:"courier-mb-4",children:[(0,ne.jsx)(q,{children:(0,ne.jsx)(lt,{...n,defaultValue:de.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ne.jsx)(K,{})]})})]})]}):null},"TextBlockForm");var Kg=require("@tiptap/react");var lm=zg.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){St(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:de.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):de.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:de.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):de.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:de.textAlign,parseHTML:t=>t.style.textAlign||de.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:de.backgroundColor,parseHTML:t=>t.style.backgroundColor||de.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:de.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):de.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderRadius:{default:de.borderRadius,parseHTML:t=>t.style.borderRadius?parseInt(t.style.borderRadius):de.borderRadius,renderHTML:t=>({style:`border-radius: ${t.borderRadius}px`})},borderColor:{default:de.borderColor,parseHTML:t=>t.style.borderColor||de.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},textColor:{default:de.textColor,parseHTML:t=>t.style.color||de.textColor,renderHTML:t=>({style:`color: ${t.textColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,Gg.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,Kg.ReactNodeViewRenderer)(sc)}});var lc=require("@tiptap/core"),Xg=require("@tiptap/react");var cm=require("jotai"),Je=require("react");var jt=require("react/jsx-runtime"),j0=["image/png","image/jpeg","image/gif","image/webp"],Z0=a(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderRadius:n,borderColor:i,isUploading:s,width:l,imageNaturalWidth:c,onFileSelect:u,editor:d})=>{let[f,m]=(0,Je.useState)(!1),[p,v]=(0,Je.useState)(!0),h=(0,Je.useRef)(null),g=(0,Je.useRef)(null);(0,Je.useEffect)(()=>{e&&v(!0)},[e]),(0,Je.useEffect)(()=>{if(e&&!c&&d){let w=new Image;w.onload=()=>{try{if(!d.view||!d.state)return;let E=d.view.state.selection.from;d.chain().setNodeSelection(E).updateAttributes("imageBlock",{imageNaturalWidth:w.naturalWidth}).run()}catch{}},w.src=e}},[e,c,d]);let C=(0,Je.useCallback)(w=>{var S,D;let E=(D=(S=d==null?void 0:d.view)==null?void 0:S.dom)==null?void 0:D.closest(".ProseMirror"),N=(E==null?void 0:E.clientWidth)||1e3,M=Math.min(100,w/N*100);return Math.round(M)},[d]),P=(0,Je.useMemo)(()=>C(c),[C,c]),y=(0,Je.useCallback)(w=>j0.includes(w),[]),b=(0,Je.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&Array.from(w.dataTransfer.items).some(M=>y(M.type))&&(m(!0),w.dataTransfer.dropEffect="copy")},[y]),A=(0,Je.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),m(!1)},[]),x=(0,Je.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&Array.from(w.dataTransfer.items).some(M=>y(M.type))&&m(!0)},[y]),I=(0,Je.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),m(!1);let N=Array.from(w.dataTransfer.files).find(M=>y(M.type));N&&u&&u(N)},[u,y]),T=(0,Je.useCallback)(w=>{var N;let E=(N=w.target.files)==null?void 0:N[0];E&&u&&u(E),w.target&&(w.target.value="")},[u]),k=(0,Je.useCallback)(()=>{var w;(w=h.current)==null||w.click()},[]);return e?(0,jt.jsx)("div",{className:"courier-w-full node-element",children:(0,jt.jsxs)("div",{className:R("courier-relative courier-p-1",(s||p)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(s||p)&&(0,jt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,jt.jsx)(ni,{className:"courier-w-8 courier-h-8"})}),(0,jt.jsx)("img",{ref:g,src:e,alt:t,className:R("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],s&&"courier-opacity-50",(s||p)&&"courier-invisible"),style:{maxWidth:l===P?`${c}px`:`${l}%`,borderWidth:`${o}px`,borderRadius:`${n}px`,borderColor:i,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:w=>{if(v(!1),!c&&d)try{if(!d.view||!d.state)return;setTimeout(()=>{let E=d.view.state.selection.from;d.chain().setNodeSelection(E).updateAttributes("imageBlock",{imageNaturalWidth:w.target.naturalWidth}).run()},100)}catch(E){console.warn("Editor not ready for image update:",E)}},onError:()=>v(!1)})]})}):(0,jt.jsxs)("div",{className:R("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1 courier-text-center courier-flex-wrap courier-content-center courier-p-4",f&&"courier-border-primary courier-bg-gray-50"),onDragOver:b,onDragEnter:x,onDragLeave:A,onDrop:I,style:{pointerEvents:"all"},children:[s?(0,jt.jsx)(ni,{className:"courier-w-8 courier-h-8"}):(0,jt.jsxs)(jt.Fragment,{children:[(0,jt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,jt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:k,children:"Browse"})]}),(0,jt.jsx)("input",{ref:h,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:T})]})},"ImageBlockComponent"),q0=["image/png","image/jpeg","image/gif","image/webp"],Yg=a(e=>{let t=(0,cm.useSetAtom)(ft),r=(0,cm.useSetAtom)(ae),{uploadImage:o}=zi(),n=(0,Je.useCallback)(l=>{var f,m,p;let c=(p=(m=(f=e.editor)==null?void 0:f.view)==null?void 0:m.dom)==null?void 0:p.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,Je.useEffect)(()=>{var c,u;let l=Lt(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let f=l.attrs.width||n(d.naturalWidth),m=Fn(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:f,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,Je.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Lt(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),s=(0,Je.useCallback)(async l=>{let c=Fn(e.getPos);Lt(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!q0.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let d=new FileReader;d.readAsDataURL(l),await new Promise((h,g)=>{d.onload=h,d.onerror=g});let m=(await o({file:l})).url,p=Fn(e.getPos);if(Lt(e)&&p!==null){let h=new Image;h.src=m,await new Promise((C,P)=>{h.onload=C,h.onerror=()=>P(new Error("Failed to load uploaded image"))});let g=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:g,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let f="Error uploading image";if(d instanceof Error){let v=d.message;v.includes("GraphQL error")?f="Server error: Could not process image":v.includes("network")||v.includes("fetch")?f="Network error: Could not upload image":f=v}r({message:f,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=Fn(e.getPos);Lt(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,jt.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,jt.jsx)(Z0,{...e.node.attrs,onFileSelect:s,editor:e.editor})})},"ImageBlockView");var ht={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderRadius:0,borderColor:"#000000",isUploading:!1,imageNaturalWidth:0},cc=lc.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){St(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:ht.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:ht.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:ht.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:ht.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:ht.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:ht.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:ht.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:ht.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:ht.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:ht.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,lc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,Xg.ReactNodeViewRenderer)(Yg)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...ht,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...ht,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var no=require("zod"),Qg=no.z.object({sourcePath:no.z.string(),link:no.z.string().optional(),alt:no.z.string().optional(),alignment:no.z.enum(["left","center","right"]),width:no.z.number().min(1).max(100),borderWidth:no.z.number(),borderRadius:no.z.number(),borderColor:no.z.string(),isUploading:no.z.boolean().optional(),imageNaturalWidth:no.z.number()});var eh=require("@hookform/resolvers/zod"),th=require("jotai"),rh=require("lucide-react"),Rt=require("react"),oh=require("react-hook-form");var U=require("react/jsx-runtime"),nh=a(({element:e,editor:t})=>{var k,w,E,N;let r=(0,Rt.useRef)(null),o=(0,Rt.useRef)(null),n=(0,Rt.useRef)(null),[i,s]=(0,Rt.useState)(""),[l,c]=(0,Rt.useState)(!1),[u,d]=(0,Rt.useState)(((k=e==null?void 0:e.attrs)==null?void 0:k.imageNaturalWidth)||0),[f,m]=(0,Rt.useState)(!1),p=(0,th.useSetAtom)(ae),{uploadImage:v}=zi(),h=(0,oh.useForm)({resolver:(0,eh.zodResolver)(Qg),defaultValues:{...ht,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:g}=zt({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,Rt.useEffect)(()=>{var S;let M=(S=e==null?void 0:e.attrs)==null?void 0:S.sourcePath;if(M&&!u){let D=new Image;D.onload=()=>{d(D.naturalWidth);let L={...h.getValues(),imageNaturalWidth:D.naturalWidth};h.setValue("imageNaturalWidth",D.naturalWidth),g(L)},D.src=M}},[(w=e==null?void 0:e.attrs)==null?void 0:w.sourcePath,u,h,g]);let C=(0,Rt.useCallback)(M=>{var V,O;let S=(O=(V=t==null?void 0:t.view)==null?void 0:V.dom)==null?void 0:O.closest(".ProseMirror"),D=(S==null?void 0:S.clientWidth)||1e3;if(M||(M=u),!M)return 0;let L=Math.min(100,M/D*100);return Math.round(L)},[t,u]),P=(0,Rt.useCallback)(M=>{var S;M.preventDefault(),(S=r.current)==null||S.click()},[]),y=(0,Rt.useCallback)((M,S)=>{let D=C(M.naturalWidth);s(`${D}%`),c(!1),h.setValue("sourcePath",S),h.setValue("imageNaturalWidth",M.naturalWidth),h.setValue("width",D);let L={...h.getValues(),sourcePath:S,width:D,imageNaturalWidth:M.naturalWidth,isUploading:!1};g(L)},[h,g,C]),b=(0,Rt.useCallback)(M=>{if(!M){h.setValue("imageNaturalWidth",0),h.setValue("width",0),g({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let S=new Image;S.onload=()=>{let D=C(S.naturalWidth);h.setValue("imageNaturalWidth",S.naturalWidth),h.setValue("width",D);let L={...h.getValues(),sourcePath:M,width:D,imageNaturalWidth:S.naturalWidth};g(L)},S.onerror=()=>{console.debug("Image failed to load:",M)},S.src=M},[h,g,C]),A=(0,Rt.useCallback)(M=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{b(M)},500)},[b]);(0,Rt.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let x=((N=(E=t==null?void 0:t.extensionManager.extensions.find(M=>M.name==="variableSuggestion"))==null?void 0:E.options)==null?void 0:N.variables)||{},I=$r(x),T=h.getValues().sourcePath;return e?(0,U.jsxs)(et,{...h,children:[(0,U.jsx)(rr,{type:"image"}),(0,U.jsxs)("form",{ref:o,onChange:()=>{let M=h.getValues();g(M)},children:[(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,U.jsxs)(rl,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,U.jsxs)(Oa,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,U.jsx)(Gi,{value:"file",className:"courier-flex-1",children:"From file"}),(0,U.jsx)(Gi,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,U.jsx)(ol,{value:"file",children:(0,U.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,U.jsx)(Oe,{onClick:P,className:"courier-w-full",variant:"outline",type:"button",disabled:f,children:f?(0,U.jsx)(U.Fragment,{children:"Uploading..."}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rh.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,U.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:M=>{var D;let S=(D=M.target.files)==null?void 0:D[0];if(S){m(!0),h.setValue("sourcePath",""),g({...h.getValues(),sourcePath:"",isUploading:!0});let L=new FileReader;L.onload=async()=>{try{let V=(await v({file:S})).url,O=new Image;O.onload=()=>{y(O,V),m(!1)},O.onerror=()=>{p({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),m(!1),g({...h.getValues(),isUploading:!1})},O.src=V}catch(B){console.error("Error uploading image:",B),p({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),m(!1),g({...h.getValues(),isUploading:!1})}},L.onerror=()=>{p({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),m(!1),g({...h.getValues(),isUploading:!1})},L.readAsDataURL(S)}}})]})}),(0,U.jsx)(ol,{value:"url",children:(0,U.jsx)(J,{control:h.control,name:"sourcePath",render:({field:M})=>(0,U.jsxs)(Z,{className:"courier-mb-3",children:[(0,U.jsx)(q,{children:(0,U.jsx)(kr,{as:"Textarea",...M,autoResize:!0,className:"courier-max-h-[88px]",variables:I,onChange:S=>{M.onChange(S),A(S.target.value)}})}),(0,U.jsx)(K,{})]})})})]}),(0,U.jsx)(J,{control:h.control,name:"link",render:({field:M})=>(0,U.jsxs)(Z,{className:"courier-mb-3",children:[(0,U.jsx)(q,{children:(0,U.jsx)(kr,{as:"Textarea",placeholder:"Link",...M,variables:I,onChange:S=>{M.onChange(S),g({...h.getValues(),link:S.target.value})}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(J,{control:h.control,name:"alt",render:({field:M})=>(0,U.jsxs)(Z,{className:"courier-mb-4",children:[(0,U.jsx)(q,{children:(0,U.jsx)(kr,{as:"Textarea",...M,placeholder:"Alt text...",variables:I,onChange:S=>{M.onChange(S),g({...h.getValues(),alt:S.target.value})}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let M=h.getValues().width,S=h.getValues().imageNaturalWidth,D=C(S),L=M===D,B=L?"original":"fill";return(0,U.jsxs)(er,{type:"single",value:T?B:"original",onValueChange:V=>{if(!V||V===B)return;let O=V==="fill"?100:C(S);O>0&&(h.setValue("width",O),g({...h.getValues(),width:O}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!T,children:[(0,U.jsx)(tt,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,U.jsx)(tt,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:L||!T,children:"Fill"})]})})(),(0,U.jsx)(J,{control:h.control,name:"width",render:({field:M})=>(0,U.jsxs)(Z,{className:"courier-flex-1 courier-mb-3",children:[(0,U.jsx)(q,{children:(0,U.jsx)(pe,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...M,value:h.getValues().sourcePath?l?i:`${M.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:S=>{c(!0),s(S.target.value)},onChange:S=>{s(S.target.value)},onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),S.currentTarget.blur())},onBlur:S=>{c(!1);let D=parseFloat(S.target.value.replace("%",""));if(!isNaN(D)){let L=Math.min(100,Math.max(1,D));M.onChange(L),g({...h.getValues(),width:Math.round(L)})}}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(J,{control:h.control,name:"width",render:({field:M})=>(0,U.jsxs)(Z,{className:"courier-flex-1 courier-mb-3",children:[(0,U.jsx)(q,{children:(0,U.jsx)(Zu,{min:0,max:100,value:[T?M.value:0],disabled:!T,onValueChange:S=>{M.onChange(S[0]),g({...h.getValues(),width:S[0]})}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(J,{control:h.control,name:"alignment",render:({field:M})=>(0,U.jsxs)(Z,{children:[(0,U.jsx)(q,{children:(0,U.jsxs)(er,{disabled:!T,type:"single",value:M.value,onValueChange:S=>{M.onChange(S),g({...h.getValues(),alignment:S})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,U.jsx)(tt,{size:"sm",value:"left",className:"courier-w-full",children:(0,U.jsx)(Il,{className:"courier-h-4 courier-w-4"})}),(0,U.jsx)(tt,{size:"sm",value:"center",className:"courier-w-full",children:(0,U.jsx)(Ll,{className:"courier-h-4 courier-w-4"})}),(0,U.jsx)(tt,{size:"sm",value:"right",className:"courier-w-full",children:(0,U.jsx)(Rl,{className:"courier-h-4 courier-w-4"})})]})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(ye,{className:"courier-mt-6 courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,U.jsx)(J,{control:h.control,name:"borderWidth",render:({field:M})=>(0,U.jsxs)(Z,{children:[(0,U.jsx)(q,{children:(0,U.jsx)(pe,{startAdornment:(0,U.jsx)(zr,{}),type:"number",disabled:!T,min:0,...M,onChange:S=>{let D=parseInt(S.target.value)||0;M.onChange(D),g({...h.getValues(),borderWidth:D})}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(J,{control:h.control,name:"borderRadius",render:({field:M})=>(0,U.jsxs)(Z,{children:[(0,U.jsx)(q,{children:(0,U.jsx)(pe,{startAdornment:(0,U.jsx)(an,{}),type:"number",disabled:!T,min:0,...M,onChange:S=>{let D=parseInt(S.target.value)||0;M.onChange(D),g({...h.getValues(),borderRadius:D})}})}),(0,U.jsx)(K,{})]})})]}),(0,U.jsx)(J,{control:h.control,name:"borderColor",render:({field:M})=>(0,U.jsxs)(Z,{className:"courier-mb-4",children:[(0,U.jsx)(q,{children:(0,U.jsx)(lt,{...M,disabled:!T,defaultValue:ht.borderColor,onChange:S=>{M.onChange(S),g({...h.getValues(),[M.name]:S})}})}),(0,U.jsx)(K,{})]})})]})]}):null},"ImageBlockForm");var ws=require("@tiptap/core"),ih=Ae(require("@tiptap/extension-link"),1),ua=require("@tiptap/pm/state"),um=ih.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,ws.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new ua.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:s}=i,l=s.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=s.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<s.content.size&&(c=s.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,ws.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(ua.TextSelection.create(s,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(ua.TextSelection.create(s,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new ua.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,s=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let f=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(f!==d){let m=(0,ws.getMarkRange)(n.doc.resolve(c),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:f,hasVariables:!0,originalHref:f})),s=!0)}}}}),!0)),s?i:null}})]}});var ah=require("@hookform/resolvers/zod"),sh=require("jotai"),dc=require("react"),lh=require("react-hook-form"),uc=require("zod");var wo=require("react/jsx-runtime"),J0=uc.z.object({href:uc.z.string(),openInNewTab:uc.z.boolean().default(!1)}),ch=a(({editor:e,mark:t,pendingLink:r})=>{var u,d;let o=(0,sh.useSetAtom)(ml),n=(0,dc.useRef)(null),i=(0,lh.useForm)({resolver:(0,ah.zodResolver)(J0),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,dc.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let s=((d=(u=e==null?void 0:e.extensionManager.extensions.find(f=>f.name==="variableSuggestion"))==null?void 0:u.options)==null?void 0:d.variables)||{},l=$r(s),c=a(async f=>{let m=f.href.trim();if(!m){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:m,target:f.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,wo.jsxs)(et,{...i,children:[(0,wo.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,wo.jsx)("div",{className:"courier-space-y-4",children:(0,wo.jsx)(J,{control:i.control,name:"href",render:({field:f})=>(0,wo.jsxs)(Z,{children:[(0,wo.jsx)(Uo,{children:"URL"}),(0,wo.jsx)(q,{children:(0,wo.jsx)(kr,{as:"Textarea",autoResize:!0,...f,variables:l,ref:m=>{typeof f.ref=="function"&&f.ref(m),n.current=m},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),i.handleSubmit(c)())},onBlur:()=>{f.onBlur(),i.handleSubmit(c)()}})}),(0,wo.jsx)(K,{})]})})})]})},"LinkForm");var mc=require("@tiptap/core"),uh=mc.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,mc.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var gc=require("@tiptap/react"),da=require("prosemirror-state");var mn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},fc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},G0=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),K0=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(bt=0;bt<10;bt++)mn[48+bt]=mn[96+bt]=String(bt);var bt;for(bt=1;bt<=24;bt++)mn[bt+111]="F"+bt;var bt;for(bt=65;bt<=90;bt++)mn[bt]=String.fromCharCode(bt+32),fc[bt]=String.fromCharCode(bt);var bt;for(pc in mn)fc.hasOwnProperty(pc)||(fc[pc]=mn[pc]);var pc;function dh(e){var t=G0&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||K0&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?fc:mn)[e.keyCode]||e.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}a(dh,"keyName");var mh=require("prosemirror-state");var Y0=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function X0(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,s;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))Y0?s=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),s&&(r="Meta-"+r),i&&(r="Shift-"+r),r}a(X0,"normalizeKeyName");function Q0(e){let t=Object.create(null);for(let r in e)t[X0(r)]=e[r];return t}a(Q0,"normalize");function dm(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}a(dm,"modifiers");function ph(e){return new mh.Plugin({props:{handleKeyDown:ey(e)}})}a(ph,"keymap");function ey(e){let t=Q0(e);return function(r,o){let n=dh(o),i,s=t[dm(n,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[dm(n,o,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=mn[o.keyCode])&&i!=n){let l=t[dm(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}a(ey,"keydownHandler");var fh=require("uuid");var mm=uh.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){St(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,fh.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:de.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):de.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:de.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):de.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:de.textAlign,parseHTML:e=>e.style.textAlign||de.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:de.backgroundColor,parseHTML:e=>e.style.backgroundColor||de.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:de.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):de.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:de.borderRadius,parseHTML:e=>e.style.borderRadius?parseInt(e.style.borderRadius):de.borderRadius,renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:de.borderColor,parseHTML:e=>e.style.borderColor||de.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},textColor:{default:de.textColor,parseHTML:e=>e.style.color||de.textColor,renderHTML:e=>({"data-text-color":e.textColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,gc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,gc.ReactNodeViewRenderer)(sc)},addProseMirrorPlugins(){return[ph({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),s=r.end(o);if(e.from!==i||e.to!==s)return t.setSelection(da.TextSelection.create(t.doc,i,s)),!0}return!1}}),new da.Plugin({key:new da.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:s}=i,l=s.depth,c=null;for(;l>0;){let u=s.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=s.parentOffset===0,f=s.parentOffset===u.length,m=u.length===0,p=t.key==="Delete"||t.keyCode===46||t.code==="Delete",v=p?i.$from.nodeAfter:i.$from.nodeBefore,h=v!=null;if(h&&m)return!1;if(o||m&&!h||!p&&d&&!h||p&&f&&!h)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=a((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,s=n.depth,l=null;for(;s>0;){let m=n.node(s);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}s--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,f=d!=null;return f&&u?!1:c&&!f||u&&!f?!0:o?!1:(t.commands.command(({tr:m,dispatch:p})=>p?(m.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),s=r.end(o);return t.commands.setTextSelection({from:i,to:s}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}}});var gh=require("@tiptap/core"),hc=require("@tiptap/pm/state"),ty=new hc.PluginKey("selection"),pm=gh.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,s=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,f;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let m=!1;i?m=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===s:s&&(m=l.type.name===s&&l.content.size===((f=e==null?void 0:e.content)==null?void 0:f.size)),m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new hc.Plugin({key:ty,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),m=o.doc.resolve(d).node();if(m&&["paragraph","heading"].includes(m.type.name))return this.options.setSelectedNode(m),this.editor.commands.updateSelectionState(m),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),s=o.doc.resolve(i).node();return s&&["paragraph","heading"].includes(s.type.name)?(this.options.setSelectedNode(s),this.editor.commands.updateSelectionState(s),!0):!1}}})]}});var rt="top",Pt="bottom",yt="right",ct="left",bc="auto",Vn=[rt,Pt,yt,ct],pn="start",vi="end",hh="clippingParents",yc="viewport",ma="popper",bh="reference",fm=Vn.reduce(function(e,t){return e.concat([t+"-"+pn,t+"-"+vi])},[]),vc=[].concat(Vn,[bc]).reduce(function(e,t){return e.concat([t,t+"-"+pn,t+"-"+vi])},[]),ry="beforeRead",oy="read",ny="afterRead",iy="beforeMain",ay="main",sy="afterMain",ly="beforeWrite",cy="write",uy="afterWrite",yh=[ry,oy,ny,iy,ay,sy,ly,cy,uy];function Dt(e){return e?(e.nodeName||"").toLowerCase():null}a(Dt,"getNodeName");function Ge(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}a(Ge,"getWindow");function io(e){var t=Ge(e).Element;return e instanceof t||e instanceof Element}a(io,"isElement");function kt(e){var t=Ge(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}a(kt,"isHTMLElement");function pa(e){if(typeof ShadowRoot=="undefined")return!1;var t=Ge(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}a(pa,"isShadowRoot");function dy(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!kt(i)||!Dt(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(s){var l=n[s];l===!1?i.removeAttribute(s):i.setAttribute(s,l===!0?"":l)}))})}a(dy,"applyStyles");function my(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach(function(o){var n=t.elements[o],i=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:r[o]),l=s.reduce(function(c,u){return c[u]="",c},{});!kt(n)||!Dt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(c){n.removeAttribute(c)}))})}}a(my,"effect");var Es={name:"applyStyles",enabled:!0,phase:"write",fn:dy,effect:my,requires:["computeStyles"]};function Ht(e){return e.split("-")[0]}a(Ht,"getBasePlacement");var Eo=Math.max,Ci=Math.min,fn=Math.round;function fa(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}a(fa,"getUAString");function Ps(){return!/^((?!chrome|android).)*safari/i.test(fa())}a(Ps,"isLayoutViewport");function ao(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&kt(e)&&(n=e.offsetWidth>0&&fn(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&fn(o.height)/e.offsetHeight||1);var s=io(e)?Ge(e):window,l=s.visualViewport,c=!Ps()&&r,u=(o.left+(c&&l?l.offsetLeft:0))/n,d=(o.top+(c&&l?l.offsetTop:0))/i,f=o.width/n,m=o.height/i;return{width:f,height:m,top:d,right:u+f,bottom:d+m,left:u,x:u,y:d}}a(ao,"getBoundingClientRect");function xi(e){var t=ao(e),r=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:o}}a(xi,"getLayoutRect");function ks(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&pa(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}a(ks,"contains");function mr(e){return Ge(e).getComputedStyle(e)}a(mr,"getComputedStyle");function gm(e){return["table","td","th"].indexOf(Dt(e))>=0}a(gm,"isTableElement");function Zt(e){return((io(e)?e.ownerDocument:e.document)||window.document).documentElement}a(Zt,"getDocumentElement");function gn(e){return Dt(e)==="html"?e:e.assignedSlot||e.parentNode||(pa(e)?e.host:null)||Zt(e)}a(gn,"getParentNode");function vh(e){return!kt(e)||mr(e).position==="fixed"?null:e.offsetParent}a(vh,"getTrueOffsetParent");function py(e){var t=/firefox/i.test(fa()),r=/Trident/i.test(fa());if(r&&kt(e)){var o=mr(e);if(o.position==="fixed")return null}var n=gn(e);for(pa(n)&&(n=n.host);kt(n)&&["html","body"].indexOf(Dt(n))<0;){var i=mr(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}a(py,"getContainingBlock");function Po(e){for(var t=Ge(e),r=vh(e);r&&gm(r)&&mr(r).position==="static";)r=vh(r);return r&&(Dt(r)==="html"||Dt(r)==="body"&&mr(r).position==="static")?t:r||py(e)||t}a(Po,"getOffsetParent");function Ti(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}a(Ti,"getMainAxisFromPlacement");function wi(e,t,r){return Eo(e,Ci(t,r))}a(wi,"within");function Ch(e,t,r){var o=wi(e,t,r);return o>r?r:o}a(Ch,"withinMaxClamp");function Ms(){return{top:0,right:0,bottom:0,left:0}}a(Ms,"getFreshSideObject");function Ns(e){return Object.assign({},Ms(),e)}a(Ns,"mergePaddingObject");function As(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}a(As,"expandToHashMap");var fy=a(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Ns(typeof t!="number"?t:As(t,Vn))},"toPaddingObject");function gy(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,s=r.modifiersData.popperOffsets,l=Ht(r.placement),c=Ti(l),u=[ct,yt].indexOf(l)>=0,d=u?"height":"width";if(!(!i||!s)){var f=fy(n.padding,r),m=xi(i),p=c==="y"?rt:ct,v=c==="y"?Pt:yt,h=r.rects.reference[d]+r.rects.reference[c]-s[c]-r.rects.popper[d],g=s[c]-r.rects.reference[c],C=Po(i),P=C?c==="y"?C.clientHeight||0:C.clientWidth||0:0,y=h/2-g/2,b=f[p],A=P-m[d]-f[v],x=P/2-m[d]/2+y,I=wi(b,x,A),T=c;r.modifiersData[o]=(t={},t[T]=I,t.centerOffset=I-x,t)}}a(gy,"arrow");function hy(e){var t=e.state,r=e.options,o=r.element,n=o===void 0?"[data-popper-arrow]":o;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||ks(t.elements.popper,n)&&(t.elements.arrow=n))}a(hy,"effect");var xh={name:"arrow",enabled:!0,phase:"main",fn:gy,effect:hy,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function so(e){return e.split("-")[1]}a(so,"getVariation");var by={top:"auto",right:"auto",bottom:"auto",left:"auto"};function yy(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:fn(r*n)/n||0,y:fn(o*n)/n||0}}a(yy,"roundOffsetsByDPR");function Th(e){var t,r=e.popper,o=e.popperRect,n=e.placement,i=e.variation,s=e.offsets,l=e.position,c=e.gpuAcceleration,u=e.adaptive,d=e.roundOffsets,f=e.isFixed,m=s.x,p=m===void 0?0:m,v=s.y,h=v===void 0?0:v,g=typeof d=="function"?d({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var C=s.hasOwnProperty("x"),P=s.hasOwnProperty("y"),y=ct,b=rt,A=window;if(u){var x=Po(r),I="clientHeight",T="clientWidth";if(x===Ge(r)&&(x=Zt(r),mr(x).position!=="static"&&l==="absolute"&&(I="scrollHeight",T="scrollWidth")),x=x,n===rt||(n===ct||n===yt)&&i===vi){b=Pt;var k=f&&x===A&&A.visualViewport?A.visualViewport.height:x[I];h-=k-o.height,h*=c?1:-1}if(n===ct||(n===rt||n===Pt)&&i===vi){y=yt;var w=f&&x===A&&A.visualViewport?A.visualViewport.width:x[T];p-=w-o.width,p*=c?1:-1}}var E=Object.assign({position:l},u&&by),N=d===!0?yy({x:p,y:h},Ge(r)):{x:p,y:h};if(p=N.x,h=N.y,c){var M;return Object.assign({},E,(M={},M[b]=P?"0":"",M[y]=C?"0":"",M.transform=(A.devicePixelRatio||1)<=1?"translate("+p+"px, "+h+"px)":"translate3d("+p+"px, "+h+"px, 0)",M))}return Object.assign({},E,(t={},t[b]=P?h+"px":"",t[y]=C?p+"px":"",t.transform="",t))}a(Th,"mapToStyles");function vy(e){var t=e.state,r=e.options,o=r.gpuAcceleration,n=o===void 0?!0:o,i=r.adaptive,s=i===void 0?!0:i,l=r.roundOffsets,c=l===void 0?!0:l,u={placement:Ht(t.placement),variation:so(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Th(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Th(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}a(vy,"computeStyles");var wh={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:vy,data:{}};var Cc={passive:!0};function Cy(e){var t=e.state,r=e.instance,o=e.options,n=o.scroll,i=n===void 0?!0:n,s=o.resize,l=s===void 0?!0:s,c=Ge(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,Cc)}),l&&c.addEventListener("resize",r.update,Cc),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,Cc)}),l&&c.removeEventListener("resize",r.update,Cc)}}a(Cy,"effect");var Eh={name:"eventListeners",enabled:!0,phase:"write",fn:a(function(){},"fn"),effect:Cy,data:{}};var xy={left:"right",right:"left",bottom:"top",top:"bottom"};function ga(e){return e.replace(/left|right|bottom|top/g,function(t){return xy[t]})}a(ga,"getOppositePlacement");var Ty={start:"end",end:"start"};function xc(e){return e.replace(/start|end/g,function(t){return Ty[t]})}a(xc,"getOppositeVariationPlacement");function Ei(e){var t=Ge(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}a(Ei,"getWindowScroll");function Pi(e){return ao(Zt(e)).left+Ei(e).scrollLeft}a(Pi,"getWindowScrollBarX");function hm(e,t){var r=Ge(e),o=Zt(e),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(n){i=n.width,s=n.height;var u=Ps();(u||!u&&t==="fixed")&&(l=n.offsetLeft,c=n.offsetTop)}return{width:i,height:s,x:l+Pi(e),y:c}}a(hm,"getViewportRect");function bm(e){var t,r=Zt(e),o=Ei(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=Eo(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=Eo(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-o.scrollLeft+Pi(e),c=-o.scrollTop;return mr(n||r).direction==="rtl"&&(l+=Eo(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:s,x:l,y:c}}a(bm,"getDocumentRect");function ki(e){var t=mr(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}a(ki,"isScrollParent");function Tc(e){return["html","body","#document"].indexOf(Dt(e))>=0?e.ownerDocument.body:kt(e)&&ki(e)?e:Tc(gn(e))}a(Tc,"getScrollParent");function On(e,t){var r;t===void 0&&(t=[]);var o=Tc(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=Ge(o),s=n?[i].concat(i.visualViewport||[],ki(o)?o:[]):o,l=t.concat(s);return n?l:l.concat(On(gn(s)))}a(On,"listScrollParents");function ha(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}a(ha,"rectToClientRect");function wy(e,t){var r=ao(e,!1,t==="fixed");return r.top=r.top+e.clientTop,r.left=r.left+e.clientLeft,r.bottom=r.top+e.clientHeight,r.right=r.left+e.clientWidth,r.width=e.clientWidth,r.height=e.clientHeight,r.x=r.left,r.y=r.top,r}a(wy,"getInnerBoundingClientRect");function Ph(e,t,r){return t===yc?ha(hm(e,r)):io(t)?wy(t,r):ha(bm(Zt(e)))}a(Ph,"getClientRectFromMixedType");function Ey(e){var t=On(gn(e)),r=["absolute","fixed"].indexOf(mr(e).position)>=0,o=r&&kt(e)?Po(e):e;return io(o)?t.filter(function(n){return io(n)&&ks(n,o)&&Dt(n)!=="body"}):[]}a(Ey,"getClippingParents");function ym(e,t,r,o){var n=t==="clippingParents"?Ey(e):[].concat(t),i=[].concat(n,[r]),s=i[0],l=i.reduce(function(c,u){var d=Ph(e,u,o);return c.top=Eo(d.top,c.top),c.right=Ci(d.right,c.right),c.bottom=Ci(d.bottom,c.bottom),c.left=Eo(d.left,c.left),c},Ph(e,s,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}a(ym,"getClippingRect");function Ss(e){var t=e.reference,r=e.element,o=e.placement,n=o?Ht(o):null,i=o?so(o):null,s=t.x+t.width/2-r.width/2,l=t.y+t.height/2-r.height/2,c;switch(n){case rt:c={x:s,y:t.y-r.height};break;case Pt:c={x:s,y:t.y+t.height};break;case yt:c={x:t.x+t.width,y:l};break;case ct:c={x:t.x-r.width,y:l};break;default:c={x:t.x,y:t.y}}var u=n?Ti(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case pn:c[u]=c[u]-(t[d]/2-r[d]/2);break;case vi:c[u]=c[u]+(t[d]/2-r[d]/2);break;default:}}return c}a(Ss,"computeOffsets");function ko(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=o===void 0?e.placement:o,i=r.strategy,s=i===void 0?e.strategy:i,l=r.boundary,c=l===void 0?hh:l,u=r.rootBoundary,d=u===void 0?yc:u,f=r.elementContext,m=f===void 0?ma:f,p=r.altBoundary,v=p===void 0?!1:p,h=r.padding,g=h===void 0?0:h,C=Ns(typeof g!="number"?g:As(g,Vn)),P=m===ma?bh:ma,y=e.rects.popper,b=e.elements[v?P:m],A=ym(io(b)?b:b.contextElement||Zt(e.elements.popper),c,d,s),x=ao(e.elements.reference),I=Ss({reference:x,element:y,strategy:"absolute",placement:n}),T=ha(Object.assign({},y,I)),k=m===ma?T:x,w={top:A.top-k.top+C.top,bottom:k.bottom-A.bottom+C.bottom,left:A.left-k.left+C.left,right:k.right-A.right+C.right},E=e.modifiersData.offset;if(m===ma&&E){var N=E[n];Object.keys(w).forEach(function(M){var S=[yt,Pt].indexOf(M)>=0?1:-1,D=[rt,Pt].indexOf(M)>=0?"y":"x";w[M]+=N[D]*S})}return w}a(ko,"detectOverflow");function vm(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=r.boundary,i=r.rootBoundary,s=r.padding,l=r.flipVariations,c=r.allowedAutoPlacements,u=c===void 0?vc:c,d=so(o),f=d?l?fm:fm.filter(function(v){return so(v)===d}):Vn,m=f.filter(function(v){return u.indexOf(v)>=0});m.length===0&&(m=f);var p=m.reduce(function(v,h){return v[h]=ko(e,{placement:h,boundary:n,rootBoundary:i,padding:s})[Ht(h)],v},{});return Object.keys(p).sort(function(v,h){return p[v]-p[h]})}a(vm,"computeAutoPlacement");function Py(e){if(Ht(e)===bc)return[];var t=ga(e);return[xc(e),t,xc(t)]}a(Py,"getExpandedFallbackPlacements");function ky(e){var t=e.state,r=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!0:s,c=r.fallbackPlacements,u=r.padding,d=r.boundary,f=r.rootBoundary,m=r.altBoundary,p=r.flipVariations,v=p===void 0?!0:p,h=r.allowedAutoPlacements,g=t.options.placement,C=Ht(g),P=C===g,y=c||(P||!v?[ga(g)]:Py(g)),b=[g].concat(y).reduce(function(re,ee){return re.concat(Ht(ee)===bc?vm(t,{placement:ee,boundary:d,rootBoundary:f,padding:u,flipVariations:v,allowedAutoPlacements:h}):ee)},[]),A=t.rects.reference,x=t.rects.popper,I=new Map,T=!0,k=b[0],w=0;w<b.length;w++){var E=b[w],N=Ht(E),M=so(E)===pn,S=[rt,Pt].indexOf(N)>=0,D=S?"width":"height",L=ko(t,{placement:E,boundary:d,rootBoundary:f,altBoundary:m,padding:u}),B=S?M?yt:ct:M?Pt:rt;A[D]>x[D]&&(B=ga(B));var V=ga(B),O=[];if(i&&O.push(L[N]<=0),l&&O.push(L[B]<=0,L[V]<=0),O.every(function(re){return re})){k=E,T=!1;break}I.set(E,O)}if(T)for(var j=v?3:1,W=a(function(ee){var F=b.find(function(G){var ce=I.get(G);if(ce)return ce.slice(0,ee).every(function(ge){return ge})});if(F)return k=F,"break"},"_loop"),_=j;_>0;_--){var Q=W(_);if(Q==="break")break}t.placement!==k&&(t.modifiersData[o]._skip=!0,t.placement=k,t.reset=!0)}}a(ky,"flip");var kh={name:"flip",enabled:!0,phase:"main",fn:ky,requiresIfExists:["offset"],data:{_skip:!1}};function Mh(e,t,r){return r===void 0&&(r={x:0,y:0}),{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}a(Mh,"getSideOffsets");function Nh(e){return[rt,yt,Pt,ct].some(function(t){return e[t]>=0})}a(Nh,"isAnySideFullyClipped");function My(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,s=ko(t,{elementContext:"reference"}),l=ko(t,{altBoundary:!0}),c=Mh(s,o),u=Mh(l,n,i),d=Nh(c),f=Nh(u);t.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:f},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":f})}a(My,"hide");var Ah={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:My};function Ny(e,t,r){var o=Ht(e),n=[ct,rt].indexOf(o)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},t,{placement:e})):r,s=i[0],l=i[1];return s=s||0,l=(l||0)*n,[ct,yt].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}a(Ny,"distanceAndSkiddingToXY");function Ay(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,s=vc.reduce(function(d,f){return d[f]=Ny(f,t.rects,i),d},{}),l=s[t.placement],c=l.x,u=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=u),t.modifiersData[o]=s}a(Ay,"offset");var Sh={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Ay};function Sy(e){var t=e.state,r=e.name;t.modifiersData[r]=Ss({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}a(Sy,"popperOffsets");var Ih={name:"popperOffsets",enabled:!0,phase:"read",fn:Sy,data:{}};function Cm(e){return e==="x"?"y":"x"}a(Cm,"getAltAxis");function Iy(e){var t=e.state,r=e.options,o=e.name,n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!1:s,c=r.boundary,u=r.rootBoundary,d=r.altBoundary,f=r.padding,m=r.tether,p=m===void 0?!0:m,v=r.tetherOffset,h=v===void 0?0:v,g=ko(t,{boundary:c,rootBoundary:u,padding:f,altBoundary:d}),C=Ht(t.placement),P=so(t.placement),y=!P,b=Ti(C),A=Cm(b),x=t.modifiersData.popperOffsets,I=t.rects.reference,T=t.rects.popper,k=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,w=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),E=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,N={x:0,y:0};if(x){if(i){var M,S=b==="y"?rt:ct,D=b==="y"?Pt:yt,L=b==="y"?"height":"width",B=x[b],V=B+g[S],O=B-g[D],j=p?-T[L]/2:0,W=P===pn?I[L]:T[L],_=P===pn?-T[L]:-I[L],Q=t.elements.arrow,re=p&&Q?xi(Q):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Ms(),F=ee[S],G=ee[D],ce=wi(0,I[L],re[L]),ge=y?I[L]/2-j-ce-F-w.mainAxis:W-ce-F-w.mainAxis,fe=y?-I[L]/2+j+ce+G+w.mainAxis:_+ce+G+w.mainAxis,Ne=t.elements.arrow&&Po(t.elements.arrow),mt=Ne?b==="y"?Ne.clientTop||0:Ne.clientLeft||0:0,ue=(M=E==null?void 0:E[b])!=null?M:0,Re=B+ge-ue-mt,ke=B+fe-ue,nt=wi(p?Ci(V,Re):V,B,p?Eo(O,ke):O);x[b]=nt,N[b]=nt-B}if(l){var it,Yt=b==="x"?rt:ct,Xt=b==="x"?Pt:yt,at=x[A],pt=A==="y"?"height":"width",yr=at+g[Yt],Qt=at-g[Xt],ie=[rt,ct].indexOf(C)!==-1,vr=(it=E==null?void 0:E[A])!=null?it:0,Xr=ie?yr:at-I[pt]-T[pt]-vr+w.altAxis,Qr=ie?at+I[pt]+T[pt]-vr-w.altAxis:Qt,Fo=p&&ie?Ch(Xr,at,Qr):wi(p?Xr:yr,at,p?Qr:Qt);x[A]=Fo,N[A]=Fo-at}t.modifiersData[o]=N}}a(Iy,"preventOverflow");var Lh={name:"preventOverflow",enabled:!0,phase:"main",fn:Iy,requiresIfExists:["offset"]};function xm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}a(xm,"getHTMLElementScroll");function Tm(e){return e===Ge(e)||!kt(e)?Ei(e):xm(e)}a(Tm,"getNodeScroll");function Ly(e){var t=e.getBoundingClientRect(),r=fn(t.width)/e.offsetWidth||1,o=fn(t.height)/e.offsetHeight||1;return r!==1||o!==1}a(Ly,"isElementScaled");function wm(e,t,r){r===void 0&&(r=!1);var o=kt(t),n=kt(t)&&Ly(t),i=Zt(t),s=ao(e,n,r),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!r)&&((Dt(t)!=="body"||ki(i))&&(l=Tm(t)),kt(t)?(c=ao(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=Pi(i))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}a(wm,"getCompositeRect");function Ry(e){var t=new Map,r=new Set,o=[];e.forEach(function(i){t.set(i.name,i)});function n(i){r.add(i.name);var s=[].concat(i.requires||[],i.requiresIfExists||[]);s.forEach(function(l){if(!r.has(l)){var c=t.get(l);c&&n(c)}}),o.push(i)}return a(n,"sort"),e.forEach(function(i){r.has(i.name)||n(i)}),o}a(Ry,"order");function Em(e){var t=Ry(e);return yh.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}a(Em,"orderModifiers");function Pm(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}a(Pm,"debounce");function km(e){var t=e.reduce(function(r,o){var n=r[o.name];return r[o.name]=n?Object.assign({},n,o,{options:Object.assign({},n.options,o.options),data:Object.assign({},n.data,o.data)}):o,r},{});return Object.keys(t).map(function(r){return t[r]})}a(km,"mergeByName");var Rh={placement:"bottom",modifiers:[],strategy:"absolute"};function Dh(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}a(Dh,"areValidElements");function Hh(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?Rh:n;return a(function(l,c,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},Rh,i),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},f=[],m=!1,p={state:d,setOptions:a(function(C){var P=typeof C=="function"?C(d.options):C;h(),d.options=Object.assign({},i,d.options,P),d.scrollParents={reference:io(l)?On(l):l.contextElement?On(l.contextElement):[],popper:On(c)};var y=Em(km([].concat(o,d.options.modifiers)));return d.orderedModifiers=y.filter(function(b){return b.enabled}),v(),p.update()},"setOptions"),forceUpdate:a(function(){if(!m){var C=d.elements,P=C.reference,y=C.popper;if(Dh(P,y)){d.rects={reference:wm(P,Po(y),d.options.strategy==="fixed"),popper:xi(y)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(w){return d.modifiersData[w.name]=Object.assign({},w.data)});for(var b=0;b<d.orderedModifiers.length;b++){if(d.reset===!0){d.reset=!1,b=-1;continue}var A=d.orderedModifiers[b],x=A.fn,I=A.options,T=I===void 0?{}:I,k=A.name;typeof x=="function"&&(d=x({state:d,options:T,name:k,instance:p})||d)}}}},"forceUpdate"),update:Pm(function(){return new Promise(function(g){p.forceUpdate(),g(d)})}),destroy:a(function(){h(),m=!0},"destroy")};if(!Dh(l,c))return p;p.setOptions(u).then(function(g){!m&&u.onFirstUpdate&&u.onFirstUpdate(g)});function v(){d.orderedModifiers.forEach(function(g){var C=g.name,P=g.options,y=P===void 0?{}:P,b=g.effect;if(typeof b=="function"){var A=b({state:d,name:C,instance:p,options:y}),x=a(function(){},"noopFn");f.push(A||x)}})}a(v,"runModifierEffects");function h(){f.forEach(function(g){return g()}),f=[]}return a(h,"cleanupModifierEffects"),p},"createPopper")}a(Hh,"popperGenerator");var Dy=[Eh,Ih,wh,Es,Sh,kh,Lh,xh,Ah],Mm=Hh({defaultModifiers:Dy});var Hy="tippy-box",jh="tippy-content",By="tippy-backdrop",Zh="tippy-arrow",qh="tippy-svg-arrow",Mi={passive:!0,capture:!0},Jh=a(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function Nm(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}a(Nm,"getValueAtIndexOrReturn");function Dm(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}a(Dm,"isType");function Gh(e,t){return typeof e=="function"?e.apply(void 0,t):e}a(Gh,"invokeWithArgsOrReturn");function Bh(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}a(Bh,"debounce");function Fy(e){return e.split(/\s+/).filter(Boolean)}a(Fy,"splitBySpaces");function ba(e){return[].concat(e)}a(ba,"normalizeToArray");function Fh(e,t){e.indexOf(t)===-1&&e.push(t)}a(Fh,"pushIfUnique");function Vy(e){return e.filter(function(t,r){return e.indexOf(t)===r})}a(Vy,"unique");function Oy(e){return e.split("-")[0]}a(Oy,"getBasePlacement");function Ec(e){return[].slice.call(e)}a(Ec,"arrayFrom");function Vh(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}a(Vh,"removeUndefinedProps");function Is(){return document.createElement("div")}a(Is,"div");function Pc(e){return["Element","Fragment"].some(function(t){return Dm(e,t)})}a(Pc,"isElement");function Wy(e){return Dm(e,"NodeList")}a(Wy,"isNodeList");function Uy(e){return Dm(e,"MouseEvent")}a(Uy,"isMouseEvent");function zy(e){return!!(e&&e._tippy&&e._tippy.reference===e)}a(zy,"isReferenceElement");function _y(e){return Pc(e)?[e]:Wy(e)?Ec(e):Array.isArray(e)?e:Ec(document.querySelectorAll(e))}a(_y,"getArrayOfElements");function Am(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}a(Am,"setTransitionDuration");function Oh(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}a(Oh,"setVisibilityState");function $y(e){var t,r=ba(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}a($y,"getOwnerDocument");function jy(e,t){var r=t.clientX,o=t.clientY;return e.every(function(n){var i=n.popperRect,s=n.popperState,l=n.props,c=l.interactiveBorder,u=Oy(s.placement),d=s.modifiersData.offset;if(!d)return!0;var f=u==="bottom"?d.top.y:0,m=u==="top"?d.bottom.y:0,p=u==="right"?d.left.x:0,v=u==="left"?d.right.x:0,h=i.top-o+f>c,g=o-i.bottom-m>c,C=i.left-r+p>c,P=r-i.right-v>c;return h||g||C||P})}a(jy,"isCursorOutsideInteractiveBorder");function Sm(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}a(Sm,"updateTransitionEndListener");function Wh(e,t){for(var r=t;r;){var o;if(e.contains(r))return!0;r=r.getRootNode==null||(o=r.getRootNode())==null?void 0:o.host}return!1}a(Wh,"actualContains");var qo={isTouch:!1},Uh=0;function Zy(){qo.isTouch||(qo.isTouch=!0,window.performance&&document.addEventListener("mousemove",Kh))}a(Zy,"onDocumentTouchStart");function Kh(){var e=performance.now();e-Uh<20&&(qo.isTouch=!1,document.removeEventListener("mousemove",Kh)),Uh=e}a(Kh,"onDocumentMouseMove");function qy(){var e=document.activeElement;if(zy(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}a(qy,"onWindowBlur");function Jy(){document.addEventListener("touchstart",Zy,Mi),window.addEventListener("blur",qy)}a(Jy,"bindGlobalEventListeners");var Gy=typeof window!="undefined"&&typeof document!="undefined",Ky=Gy?!!window.msCrypto:!1;var Yy={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Xy={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Mo=Object.assign({appendTo:Jh,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:a(function(){},"onAfterUpdate"),onBeforeUpdate:a(function(){},"onBeforeUpdate"),onCreate:a(function(){},"onCreate"),onDestroy:a(function(){},"onDestroy"),onHidden:a(function(){},"onHidden"),onHide:a(function(){},"onHide"),onMount:a(function(){},"onMount"),onShow:a(function(){},"onShow"),onShown:a(function(){},"onShown"),onTrigger:a(function(){},"onTrigger"),onUntrigger:a(function(){},"onUntrigger"),onClickOutside:a(function(){},"onClickOutside"),placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},Yy,Xy),Qy=Object.keys(Mo),ev=a(function(t){var r=Object.keys(t);r.forEach(function(o){Mo[o]=t[o]})},"setDefaultProps");function Yh(e){var t=e.plugins||[],r=t.reduce(function(o,n){var i=n.name,s=n.defaultValue;if(i){var l;o[i]=e[i]!==void 0?e[i]:(l=Mo[i])!=null?l:s}return o},{});return Object.assign({},e,r)}a(Yh,"getExtendedPassedProps");function tv(e,t){var r=t?Object.keys(Yh(Object.assign({},Mo,{plugins:t}))):Qy,o=r.reduce(function(n,i){var s=(e.getAttribute("data-tippy-"+i)||"").trim();if(!s)return n;if(i==="content")n[i]=s;else try{n[i]=JSON.parse(s)}catch{n[i]=s}return n},{});return o}a(tv,"getDataAttributeProps");function zh(e,t){var r=Object.assign({},t,{content:Gh(t.content,[e])},t.ignoreAttributes?{}:tv(e,t.plugins));return r.aria=Object.assign({},Mo.aria,r.aria),r.aria={expanded:r.aria.expanded==="auto"?t.interactive:r.aria.expanded,content:r.aria.content==="auto"?t.interactive?null:"describedby":r.aria.content},r}a(zh,"evaluateProps");var rv=a(function(){return"innerHTML"},"innerHTML");function Lm(e,t){e[rv()]=t}a(Lm,"dangerouslySetInnerHTML");function _h(e){var t=Is();return e===!0?t.className=Zh:(t.className=qh,Pc(e)?t.appendChild(e):Lm(t,e)),t}a(_h,"createArrowElement");function $h(e,t){Pc(t.content)?(Lm(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Lm(e,t.content):e.textContent=t.content)}a($h,"setContent");function Rm(e){var t=e.firstElementChild,r=Ec(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(jh)}),arrow:r.find(function(o){return o.classList.contains(Zh)||o.classList.contains(qh)}),backdrop:r.find(function(o){return o.classList.contains(By)})}}a(Rm,"getChildren");function Xh(e){var t=Is(),r=Is();r.className=Hy,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=Is();o.className=jh,o.setAttribute("data-state","hidden"),$h(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,s){var l=Rm(t),c=l.box,u=l.content,d=l.arrow;s.theme?c.setAttribute("data-theme",s.theme):c.removeAttribute("data-theme"),typeof s.animation=="string"?c.setAttribute("data-animation",s.animation):c.removeAttribute("data-animation"),s.inertia?c.setAttribute("data-inertia",""):c.removeAttribute("data-inertia"),c.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?c.setAttribute("role",s.role):c.removeAttribute("role"),(i.content!==s.content||i.allowHTML!==s.allowHTML)&&$h(u,e.props),s.arrow?d?i.arrow!==s.arrow&&(c.removeChild(d),c.appendChild(_h(s.arrow))):c.appendChild(_h(s.arrow)):d&&c.removeChild(d)}return a(n,"onUpdate"),{popper:t,onUpdate:n}}a(Xh,"render");Xh.$$tippy=!0;var ov=1,wc=[],Im=[];function nv(e,t){var r=zh(e,Object.assign({},Mo,Yh(Vh(t)))),o,n,i,s=!1,l=!1,c=!1,u=!1,d,f,m,p=[],v=Bh(Re,r.interactiveDebounce),h,g=ov++,C=null,P=Vy(r.plugins),y={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},b={id:g,reference:e,popper:Is(),popperInstance:C,props:r,state:y,plugins:P,clearDelayTimeouts:Xr,setProps:Qr,setContent:Fo,show:$n,hide:jn,hideWithInteractivity:Zn,enable:ie,disable:vr,unmount:qn,destroy:Jn};if(!r.render)return b;var A=r.render(b),x=A.popper,I=A.onUpdate;x.setAttribute("data-tippy-root",""),x.id="tippy-"+b.id,b.popper=x,e._tippy=b,x._tippy=b;var T=P.map(function(H){return H.fn(b)}),k=e.hasAttribute("aria-expanded");return Ne(),j(),B(),V("onCreate",[b]),r.showOnCreate&&yr(),x.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),x.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&S().addEventListener("mousemove",v)}),b;function w(){var H=b.props.touch;return Array.isArray(H)?H:[H,0]}a(w,"getNormalizedTouchSettings");function E(){return w()[0]==="hold"}a(E,"getIsCustomTouchBehavior");function N(){var H;return!!((H=b.props.render)!=null&&H.$$tippy)}a(N,"getIsDefaultRenderFn");function M(){return h||e}a(M,"getCurrentTarget");function S(){var H=M().parentNode;return H?$y(H):document}a(S,"getDocument");function D(){return Rm(x)}a(D,"getDefaultTemplateChildren");function L(H){return b.state.isMounted&&!b.state.isVisible||qo.isTouch||d&&d.type==="focus"?0:Nm(b.props.delay,H?0:1,Mo.delay)}a(L,"getDelay");function B(H){H===void 0&&(H=!1),x.style.pointerEvents=b.props.interactive&&!H?"":"none",x.style.zIndex=""+b.props.zIndex}a(B,"handleStyles");function V(H,Y,oe){if(oe===void 0&&(oe=!0),T.forEach(function(ve){ve[H]&&ve[H].apply(ve,Y)}),oe){var Pe;(Pe=b.props)[H].apply(Pe,Y)}}a(V,"invokeHook");function O(){var H=b.props.aria;if(H.content){var Y="aria-"+H.content,oe=x.id,Pe=ba(b.props.triggerTarget||e);Pe.forEach(function(ve){var st=ve.getAttribute(Y);if(b.state.isVisible)ve.setAttribute(Y,st?st+" "+oe:oe);else{var Nt=st&&st.replace(oe,"").trim();Nt?ve.setAttribute(Y,Nt):ve.removeAttribute(Y)}})}}a(O,"handleAriaContentAttribute");function j(){if(!(k||!b.props.aria.expanded)){var H=ba(b.props.triggerTarget||e);H.forEach(function(Y){b.props.interactive?Y.setAttribute("aria-expanded",b.state.isVisible&&Y===M()?"true":"false"):Y.removeAttribute("aria-expanded")})}}a(j,"handleAriaExpandedAttribute");function W(){S().removeEventListener("mousemove",v),wc=wc.filter(function(H){return H!==v})}a(W,"cleanupInteractiveMouseListeners");function _(H){if(!(qo.isTouch&&(c||H.type==="mousedown"))){var Y=H.composedPath&&H.composedPath()[0]||H.target;if(!(b.props.interactive&&Wh(x,Y))){if(ba(b.props.triggerTarget||e).some(function(oe){return Wh(oe,Y)})){if(qo.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else V("onClickOutside",[b,H]);b.props.hideOnClick===!0&&(b.clearDelayTimeouts(),b.hide(),l=!0,setTimeout(function(){l=!1}),b.state.isMounted||F())}}}a(_,"onDocumentPress");function Q(){c=!0}a(Q,"onTouchMove");function re(){c=!1}a(re,"onTouchStart");function ee(){var H=S();H.addEventListener("mousedown",_,!0),H.addEventListener("touchend",_,Mi),H.addEventListener("touchstart",re,Mi),H.addEventListener("touchmove",Q,Mi)}a(ee,"addDocumentPress");function F(){var H=S();H.removeEventListener("mousedown",_,!0),H.removeEventListener("touchend",_,Mi),H.removeEventListener("touchstart",re,Mi),H.removeEventListener("touchmove",Q,Mi)}a(F,"removeDocumentPress");function G(H,Y){ge(H,function(){!b.state.isVisible&&x.parentNode&&x.parentNode.contains(x)&&Y()})}a(G,"onTransitionedOut");function ce(H,Y){ge(H,Y)}a(ce,"onTransitionedIn");function ge(H,Y){var oe=D().box;function Pe(ve){ve.target===oe&&(Sm(oe,"remove",Pe),Y())}if(a(Pe,"listener"),H===0)return Y();Sm(oe,"remove",f),Sm(oe,"add",Pe),f=Pe}a(ge,"onTransitionEnd");function fe(H,Y,oe){oe===void 0&&(oe=!1);var Pe=ba(b.props.triggerTarget||e);Pe.forEach(function(ve){ve.addEventListener(H,Y,oe),p.push({node:ve,eventType:H,handler:Y,options:oe})})}a(fe,"on");function Ne(){E()&&(fe("touchstart",ue,{passive:!0}),fe("touchend",ke,{passive:!0})),Fy(b.props.trigger).forEach(function(H){if(H!=="manual")switch(fe(H,ue),H){case"mouseenter":fe("mouseleave",ke);break;case"focus":fe(Ky?"focusout":"blur",nt);break;case"focusin":fe("focusout",nt);break}})}a(Ne,"addListeners");function mt(){p.forEach(function(H){var Y=H.node,oe=H.eventType,Pe=H.handler,ve=H.options;Y.removeEventListener(oe,Pe,ve)}),p=[]}a(mt,"removeListeners");function ue(H){var Y,oe=!1;if(!(!b.state.isEnabled||it(H)||l)){var Pe=((Y=d)==null?void 0:Y.type)==="focus";d=H,h=H.currentTarget,j(),!b.state.isVisible&&Uy(H)&&wc.forEach(function(ve){return ve(H)}),H.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||s)&&b.props.hideOnClick!==!1&&b.state.isVisible?oe=!0:yr(H),H.type==="click"&&(s=!oe),oe&&!Pe&&Qt(H)}}a(ue,"onTrigger");function Re(H){var Y=H.target,oe=M().contains(Y)||x.contains(Y);if(!(H.type==="mousemove"&&oe)){var Pe=pt().concat(x).map(function(ve){var st,Nt=ve._tippy,Qo=(st=Nt.popperInstance)==null?void 0:st.state;return Qo?{popperRect:ve.getBoundingClientRect(),popperState:Qo,props:r}:null}).filter(Boolean);jy(Pe,H)&&(W(),Qt(H))}}a(Re,"onMouseMove");function ke(H){var Y=it(H)||b.props.trigger.indexOf("click")>=0&&s;if(!Y){if(b.props.interactive){b.hideWithInteractivity(H);return}Qt(H)}}a(ke,"onMouseLeave");function nt(H){b.props.trigger.indexOf("focusin")<0&&H.target!==M()||b.props.interactive&&H.relatedTarget&&x.contains(H.relatedTarget)||Qt(H)}a(nt,"onBlurOrFocusOut");function it(H){return qo.isTouch?E()!==H.type.indexOf("touch")>=0:!1}a(it,"isEventListenerStopped");function Yt(){Xt();var H=b.props,Y=H.popperOptions,oe=H.placement,Pe=H.offset,ve=H.getReferenceClientRect,st=H.moveTransition,Nt=N()?Rm(x).arrow:null,Qo=ve?{getBoundingClientRect:ve,contextElement:ve.contextElement||M()}:e,Ia={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:a(function(Gn){var en=Gn.state;if(N()){var zs=D(),Ri=zs.box;["placement","reference-hidden","escaped"].forEach(function(Kn){Kn==="placement"?Ri.setAttribute("data-placement",en.placement):en.attributes.popper["data-popper-"+Kn]?Ri.setAttribute("data-"+Kn,""):Ri.removeAttribute("data-"+Kn)}),en.attributes.popper={}}},"fn")},Vo=[{name:"offset",options:{offset:Pe}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!st}},Ia];N()&&Nt&&Vo.push({name:"arrow",options:{element:Nt,padding:3}}),Vo.push.apply(Vo,(Y==null?void 0:Y.modifiers)||[]),b.popperInstance=Mm(Qo,x,Object.assign({},Y,{placement:oe,onFirstUpdate:m,modifiers:Vo}))}a(Yt,"createPopperInstance");function Xt(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}a(Xt,"destroyPopperInstance");function at(){var H=b.props.appendTo,Y,oe=M();b.props.interactive&&H===Jh||H==="parent"?Y=oe.parentNode:Y=Gh(H,[oe]),Y.contains(x)||Y.appendChild(x),b.state.isMounted=!0,Yt()}a(at,"mount");function pt(){return Ec(x.querySelectorAll("[data-tippy-root]"))}a(pt,"getNestedPopperTree");function yr(H){b.clearDelayTimeouts(),H&&V("onTrigger",[b,H]),ee();var Y=L(!0),oe=w(),Pe=oe[0],ve=oe[1];qo.isTouch&&Pe==="hold"&&ve&&(Y=ve),Y?o=setTimeout(function(){b.show()},Y):b.show()}a(yr,"scheduleShow");function Qt(H){if(b.clearDelayTimeouts(),V("onUntrigger",[b,H]),!b.state.isVisible){F();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(H.type)>=0&&s)){var Y=L(!1);Y?n=setTimeout(function(){b.state.isVisible&&b.hide()},Y):i=requestAnimationFrame(function(){b.hide()})}}a(Qt,"scheduleHide");function ie(){b.state.isEnabled=!0}a(ie,"enable");function vr(){b.hide(),b.state.isEnabled=!1}a(vr,"disable");function Xr(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}a(Xr,"clearDelayTimeouts");function Qr(H){if(!b.state.isDestroyed){V("onBeforeUpdate",[b,H]),mt();var Y=b.props,oe=zh(e,Object.assign({},Y,Vh(H),{ignoreAttributes:!0}));b.props=oe,Ne(),Y.interactiveDebounce!==oe.interactiveDebounce&&(W(),v=Bh(Re,oe.interactiveDebounce)),Y.triggerTarget&&!oe.triggerTarget?ba(Y.triggerTarget).forEach(function(Pe){Pe.removeAttribute("aria-expanded")}):oe.triggerTarget&&e.removeAttribute("aria-expanded"),j(),B(),I&&I(Y,oe),b.popperInstance&&(Yt(),pt().forEach(function(Pe){requestAnimationFrame(Pe._tippy.popperInstance.forceUpdate)})),V("onAfterUpdate",[b,H])}}a(Qr,"setProps");function Fo(H){b.setProps({content:H})}a(Fo,"setContent");function $n(){var H=b.state.isVisible,Y=b.state.isDestroyed,oe=!b.state.isEnabled,Pe=qo.isTouch&&!b.props.touch,ve=Nm(b.props.duration,0,Mo.duration);if(!(H||Y||oe||Pe)&&!M().hasAttribute("disabled")&&(V("onShow",[b],!1),b.props.onShow(b)!==!1)){if(b.state.isVisible=!0,N()&&(x.style.visibility="visible"),B(),ee(),b.state.isMounted||(x.style.transition="none"),N()){var st=D(),Nt=st.box,Qo=st.content;Am([Nt,Qo],0)}m=a(function(){var Vo;if(!(!b.state.isVisible||u)){if(u=!0,x.offsetHeight,x.style.transition=b.props.moveTransition,N()&&b.props.animation){var Li=D(),Gn=Li.box,en=Li.content;Am([Gn,en],ve),Oh([Gn,en],"visible")}O(),j(),Fh(Im,b),(Vo=b.popperInstance)==null||Vo.forceUpdate(),V("onMount",[b]),b.props.animation&&N()&&ce(ve,function(){b.state.isShown=!0,V("onShown",[b])})}},"onFirstUpdate"),at()}}a($n,"show");function jn(){var H=!b.state.isVisible,Y=b.state.isDestroyed,oe=!b.state.isEnabled,Pe=Nm(b.props.duration,1,Mo.duration);if(!(H||Y||oe)&&(V("onHide",[b],!1),b.props.onHide(b)!==!1)){if(b.state.isVisible=!1,b.state.isShown=!1,u=!1,s=!1,N()&&(x.style.visibility="hidden"),W(),F(),B(!0),N()){var ve=D(),st=ve.box,Nt=ve.content;b.props.animation&&(Am([st,Nt],Pe),Oh([st,Nt],"hidden"))}O(),j(),b.props.animation?N()&&G(Pe,b.unmount):b.unmount()}}a(jn,"hide");function Zn(H){S().addEventListener("mousemove",v),Fh(wc,v),v(H)}a(Zn,"hideWithInteractivity");function qn(){b.state.isVisible&&b.hide(),b.state.isMounted&&(Xt(),pt().forEach(function(H){H._tippy.unmount()}),x.parentNode&&x.parentNode.removeChild(x),Im=Im.filter(function(H){return H!==b}),b.state.isMounted=!1,V("onHidden",[b]))}a(qn,"unmount");function Jn(){b.state.isDestroyed||(b.clearDelayTimeouts(),b.unmount(),mt(),delete e._tippy,b.state.isDestroyed=!0,V("onDestroy",[b]))}a(Jn,"destroy")}a(nv,"createTippy");function Ls(e,t){t===void 0&&(t={});var r=Mo.plugins.concat(t.plugins||[]);Jy();var o=Object.assign({},t,{plugins:r}),n=_y(e);if(0)var i,s;var l=n.reduce(function(c,u){var d=u&&nv(u,o);return d&&c.push(d),c},[]);return Pc(e)?l[0]:l}a(Ls,"tippy");Ls.defaultProps=Mo;Ls.setDefaultProps=ev;Ls.currentInput=qo;var pL=Object.assign({},Es,{effect:a(function(t){var r=t.state,o={popper:{position:r.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(r.elements.popper.style,o.popper),r.styles=o,r.elements.arrow&&Object.assign(r.elements.arrow.style,o.arrow)},"effect")});Ls.setDefaultProps({render:Xh});var Qh=Ls;var e5=require("react"),t5=require("react/jsx-runtime"),Hm=(0,e5.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let s=R("courier-bg-white courier-rounded-lg dark:courier-bg-black",r?"courier-shadow-sm":"",o?"courier-border courier-border-border dark:courier-border-neutral-800":"",t);return(0,t5.jsx)("div",{className:s,...n,ref:i,children:e})});Hm.displayName="Surface";var kc=require("@tiptap/core"),a5=require("@tiptap/react"),s5=require("@tiptap/suggestion");var r5=require("@tiptap/react");var No={items:({query:e,editor:t})=>{var n,i;let r=((i=(n=t.extensionManager.extensions.find(s=>s.name==="variableSuggestion"))==null?void 0:n.options)==null?void 0:i.variables)||{};return $r(r).filter(s=>s.toLowerCase().includes(e.toLowerCase()))},char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,decorationTag:"span",decorationClass:"variable-suggestion",command:({editor:e,range:t,props:r})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:r}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,r=null,o=a((i,s)=>{e==null||e.updateProps({...i,selected:s})},"updateComponent"),n=a(i=>{var c,u;if(!r)return!1;let l=((c=No.items)==null?void 0:c.call(No,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return l?((u=No.command)==null||u.call(No,{editor:r.editor,range:r.range,props:l}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new r5.ReactRenderer(hs,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=Qh(i.editor.options.element,{getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect},appendTo:()=>i.editor.options.element,content:e==null?void 0:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",theme:"variable"}),e!=null&&e.element&&e.element.focus())},onUpdate(i){r=i,e==null||e.updateProps({...i,selected:e.props.selected}),i.clientRect&&(t==null||t.setProps({getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect}}))},onKeyDown(i){var c;if(!e||!r)return!1;let s=(c=No.items)==null?void 0:c.call(No,{query:e.props.query||"",editor:e.props.editor}),l=e.props.selected;if(i.event.key==="ArrowUp"){let u=(l-1+s.length)%s.length;return o(r,u),!0}if(i.event.key==="ArrowDown"){let u=(l+1)%s.length;return o(r,u),!0}return i.event.key==="Enter"?(i.event.preventDefault(),n(l)):i.event.key==="Escape"?(r.editor.chain().focus().deleteRange(r.range).run(),!0):!1},onExit(){t==null||t.destroy(),e==null||e.destroy(),r=null}}}};var o5=require("@tiptap/react"),va=require("react"),n5=require("jotai");var ya=require("react/jsx-runtime"),i5=a(({node:e,editor:t,getPos:r})=>{let n=(0,n5.useAtomValue)(Xn)[e.attrs.id],[i,s]=(0,va.useState)(!1),l=(0,va.useCallback)(()=>{if(typeof r=="function")try{let f=r();if(f==null){s(!1);return}let p=t.state.doc.resolve(f).parent;s(p&&p.type.name==="button")}catch{s(!1)}else s(!1)},[t,r]);(0,va.useEffect)(()=>{l();let f=a(()=>{l()},"handleUpdate");return t.on("update",f),t.on("selectionUpdate",f),()=>{t.off("update",f),t.off("selectionUpdate",f)}},[t,l]);let c=n?"#EFF6FF":"#FFFBEB",u=n?"#BFDBFE":"#FDE68A",d=n?void 0:"#B45309";return(0,ya.jsx)(o5.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,ya.jsxs)("span",{className:`courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] ${i?"courier-variable-in-button":""}`,style:{backgroundColor:c,borderColor:u,...i&&{color:"#000000"}},children:[(0,ya.jsx)(Hl,{color:d}),(0,ya.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:i?{color:"#000000"}:void 0,children:[e.attrs.id,n?`="${n}"`:""]})]})})},"VariableView");var Bm=kc.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,a5.ReactNodeViewRenderer)(i5)}}),Fm=kc.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...No}}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[(0,s5.Suggestion)({editor:this.editor,...this.options.suggestion})]}});var l5=require("@tiptap/core"),c5=require("@tiptap/pm/state"),Mc=require("@tiptap/pm/model");var Vm=l5.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new c5.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return ur(n)?`<span data-variable="true" data-id="${n}"></span>`:r}),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],s=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>s){let u=e.substring(s,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&ur(c))i.push(n.nodes.variable.create({id:c}));else{let u=l[0];i.push(n.text(u))}s=l.index+l[0].length}if(s<e.length){let c=e.substring(s);c&&i.push(n.text(c))}if(i.length>0){let c=Mc.Fragment.from(i),u=new Mc.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var u5=require("@tiptap/core"),Nc=require("@tiptap/pm/state");var Om=u5.Extension.create({name:"variableTypeHandler",addProseMirrorPlugins(){return[new Nc.Plugin({key:new Nc.PluginKey("variableTypeHandler"),appendTransaction:(e,t,r)=>{if(!e.some(u=>u.docChanged))return null;let{schema:n,doc:i}=r,s=/\{\{([^}]+)\}\}/g,l=[];if(i.descendants((u,d)=>{if(u.isText&&u.text){let f;for(s.lastIndex=0;(f=s.exec(u.text))!==null;){let m=f[1].trim();m&&ur(m)&&l.push({from:d+f.index,to:d+f.index+f[0].length,variableName:m})}}}),l.length===0)return null;let c=r.tr;for(let u=l.length-1;u>=0;u--){let{from:d,to:f,variableName:m}=l[u],p=c.doc.nodeAt(d);p&&p.isText&&n.nodes.variable&&c.replaceWith(d,f,n.nodes.variable.create({id:m}))}return c.docChanged?c:null}})]}});var d5=require("uuid");var iv=a((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),m5=a((e,t,r,o,n,i)=>{let s=`node-${(0,d5.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...de,...o,id:s},i),paragraph:()=>e.schema.nodes.paragraph.create({...de,...o,id:s},i),text:()=>e.schema.nodes.paragraph.create({...de,...o,id:s},i),spacer:()=>e.schema.nodes.divider.create({...Yl,...o,id:s}),divider:()=>e.schema.nodes.divider.create({...Jr,...o,id:s}),button:()=>e.schema.nodes.button.create({...$e,...o,id:s},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...ht,...o,id:s}),image:()=>e.schema.nodes.imageBlock.create({...ht,...o,id:s}),customCode:()=>e.schema.nodes.customCode.create({...un,...o,id:s}),column:()=>e.schema.nodes.column.create({...$t,...o,id:s})}[t];if(c)try{let u=e.state.tr,d=c();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=iv(e,s);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let f=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(f)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:s},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let f=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(f)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return s},"createOrDuplicateNode");var Fn=a(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),Lt=a(e=>{let t=Fn(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var p5=require("lucide-react"),f5=require("react"),qm=require("react/jsx-runtime"),g5=(0,f5.forwardRef)((e,t)=>(0,qm.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:R("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,qm.jsx)(p5.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-ring courier-fill-ring courier-pointer-events-none"})}));var Ac=require("jotai"),Nr=require("react"),h5=require("uuid");var Sc=a(e=>{let t=(0,Ac.useSetAtom)(ft),r=(0,Ac.useAtomValue)(Me),o=(0,Nr.useCallback)(g=>{let C=-1;return e.state.doc.descendants((P,y)=>{var b;return((b=P.attrs)==null?void 0:b.id)===g?(C=y,!1):!0}),C},[e]),n=(0,Nr.useCallback)((g,C)=>{var P,y,b;if(((P=r==null?void 0:r.type)==null?void 0:P.name)==="button"&&((y=r.attrs)!=null&&y.id)){let A=r.attrs.id,x=o(A);if(x>=0){let I=e.state.tr;return I.setNodeMarkup(x,void 0,{...(b=e.state.doc.nodeAt(x))==null?void 0:b.attrs,[g]:C}),e.view.dispatch(I),setTimeout(()=>{let T=o(A);if(T>=0){let k=e.state.doc.nodeAt(T);k&&t(k)}},0),!0}}return!1},[e,r,o,t]),i=(0,Nr.useCallback)(()=>{var g,C;if(((g=r==null?void 0:r.type)==null?void 0:g.name)==="button"&&((C=r.attrs)!=null&&C.id)){let P=r.attrs.id,y=o(P);if(y>=0){let b=e.state.doc.nodeAt(y);if(!b)return!1;let A={...b.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},x=e.state.tr;return x.setNodeMarkup(y,void 0,A),e.view.dispatch(x),setTimeout(()=>{let I=o(P);if(I>=0){let T=e.state.doc.nodeAt(I);T&&t(T)}},0),!0}}return!1},[e,r,o,t]),s=(0,Nr.useCallback)(()=>{var g;if(((g=r==null?void 0:r.type)==null?void 0:g.name)==="button"){let C=r.attrs.fontWeight==="bold"?"normal":"bold";if(n("fontWeight",C))return!0}return e.chain().focus().toggleBold().run()},[e,r,n]),l=(0,Nr.useCallback)(()=>{var g;if(((g=r==null?void 0:r.type)==null?void 0:g.name)==="button"){let C=r.attrs.fontStyle==="italic"?"normal":"italic";if(n("fontStyle",C))return!0}return e.chain().focus().toggleItalic().run()},[e,r,n]),c=(0,Nr.useCallback)(()=>{var g;if(((g=r==null?void 0:r.type)==null?void 0:g.name)==="button"){let C=!r.attrs.isStrike;if(n("isStrike",C))return!0}return e.chain().focus().toggleMark("strike").run()},[e,r,n]),u=(0,Nr.useCallback)(()=>{var g;if(((g=r==null?void 0:r.type)==null?void 0:g.name)==="button"){let C=!r.attrs.isUnderline;if(n("isUnderline",C))return!0}return e.chain().focus().toggleMark("underline").run()},[e,r,n]),d=(0,Nr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),f=(0,Nr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),m=(0,Nr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),p=(0,Nr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),v=(0,Nr.useCallback)((g,C)=>e.chain().focus().setLink({href:g,target:C?"_blank":""}).run(),[e]),h=(0,Nr.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:y}=e.state,b=y.$anchor;if(g){let A=b.node();(A.type.name==="paragraph"||A.type.name==="heading")&&t(A)}else for(let A=b.depth;A>0;A--){let x=b.node(A);if(x.type.name==="blockquote"){if(x.attrs.id)t(x);else{let I=b.before(A),T=`node-${(0,h5.v4)()}`,k=e.state.tr;k.setNodeMarkup(I,void 0,{...x.attrs,id:T}),e.view.dispatch(k);let w=e.state.doc.nodeAt(I);w&&t(w)}break}}}},[e,t]);return{onBold:s,onItalic:l,onStrike:c,onUnderline:u,onAlignLeft:d,onAlignCenter:f,onAlignRight:m,onAlignJustify:p,onLink:v,onQuote:h,resetButtonFormatting:i}},"useTextmenuCommands");var Ic=require("react/jsx-runtime"),av=a(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return"Drop here"}},"getPlaceholderLabel"),Lc=a(({type:e})=>(0,Ic.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,Ic.jsx)("div",{className:R("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator"),children:(0,Ic.jsx)("div",{className:"courier-text-accent-foreground",children:av(e)})})}),"DropIndicatorPlaceholder");var ut=require("react/jsx-runtime");function sv(){let[e,t]=(0,Ve.useState)(!1);return(0,Ve.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(sv,"useMountStatus");var tr=a(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let s=(0,Ve.useRef)(null),l=(0,Ve.useRef)(null),c=(0,Ve.useRef)(null),[u,d]=(0,Ve.useState)(!1),[f,m]=(0,Ve.useState)(null),[p,v]=(0,Ve.useState)(null),h=(0,Ve.useRef)(null),g=(0,Ve.useRef)(!1),C=(0,Ve.useRef)(null),P=(0,Ve.useRef)(null),y=(0,Ve.useRef)(null),b=sv(),A=u&&!b,x=(0,Ve.useCallback)(()=>{if(!o||!t)return null;let T=null;return o.state.doc.descendants((k,w,E)=>{var N;if(((N=k.attrs)==null?void 0:N.id)===t){let M=0;return E&&E.content.forEach((S,D,L)=>{S===k&&(M=L)}),T={node:k,pos:w,parent:E,index:M},!1}return!0}),T},[t,o]),I=(0,Ve.useCallback)(()=>{if(!o)return!1;let T=x();return!T||!T.parent?!1:T.index===T.parent.childCount-1},[o,x]);return(0,Ve.useEffect)(()=>{let T=s.current,k=l.current;if(!T)return;let w=$o(ns({element:T,dragHandle:k||void 0,getInitialData:()=>{var D,L,B,V,O,j;let E=x(),N="text";if(E){let W=E.node;switch(W.type.name){case"heading":N="heading";break;case"paragraph":N="text";break;case"imageBlock":N="image";break;case"divider":N=(D=W.attrs)!=null&&D.spacer?"spacer":"divider";break;case"button":N="button";break;case"customCode":N="customCode";break;case"column":N="column";break}}let M=(E==null?void 0:E.parent)===o.state.doc,S=((L=E==null?void 0:E.parent)==null?void 0:L.type.name)==="columnCell";return{id:t,type:M?"editor":S?"column-cell-item":"nested-drag",index:(B=E==null?void 0:E.index)!=null?B:0,dragType:N,pos:E==null?void 0:E.pos,originalIndex:(V=E==null?void 0:E.index)!=null?V:0,columnId:S?(O=E==null?void 0:E.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:S?(j=E==null?void 0:E.parent)==null?void 0:j.attrs.index:void 0}},onGenerateDragPreview:()=>{let E=T.querySelectorAll("[data-no-drag-preview]"),N=[];E.forEach((M,S)=>{let D=M;N[S]=D.style.display,D.style.display="none"}),requestAnimationFrame(()=>{E.forEach((M,S)=>{let D=M;D.style.display=N[S]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let E=a(N=>{P.current=N.clientY},"handleMouseMove");document.addEventListener("mousemove",E),y.current=()=>{document.removeEventListener("mousemove",E)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",y.current&&(y.current(),y.current=null),o&&o.setEditable(!0)}}),_r({element:T,getData:({input:E,element:N})=>{var j,W,_,Q;let M=x(),S=(M==null?void 0:M.parent)===o.state.doc,D=((j=M==null?void 0:M.parent)==null?void 0:j.type.name)==="columnCell",L={id:t,type:S?"editor":D?"column-cell-item":"nested-drag",index:(W=M==null?void 0:M.index)!=null?W:0,pos:M==null?void 0:M.pos,nodeType:M==null?void 0:M.node.type.name,columnId:D?(_=M==null?void 0:M.parent)==null?void 0:_.attrs.columnId:void 0,cellIndex:D?(Q=M==null?void 0:M.parent)==null?void 0:Q.attrs.index:void 0};if(N.getAttribute("data-node-type")==="column"){let re=N.getBoundingClientRect(),ee=E.clientY,F=30,G=Math.abs(ee-re.top),ce=Math.abs(ee-re.bottom);if(G>F&&ce>F)return{...L,disableDropIndicator:!0}}let V=N.closest('[data-column-cell="true"]');if(I()&&T){let re=T.getBoundingClientRect(),ee=E.clientY,F=re.top+re.height/2;if(ee>=F&&ee>re.bottom)return{...L,[Symbol.for("closestEdge")]:"bottom"}}let O=I()?["top","bottom"]:["top"];return P1(L,{input:E,element:N,allowedEdges:O})},canDrop:({source:E})=>E.data.id!==t,onDragEnter:({self:E,source:N,location:M})=>{var W,_,Q,re,ee;if(E.data.disableDropIndicator){m(null);return}C.current&&(clearTimeout(C.current),C.current=null);let S=M.current.dropTargets;if(S.length>0&&S[0].element!==T){m(null),g.current=!1,h.current=null;return}let D=is(E.data),L=D,B=I(),V=(Q=(_=(W=M==null?void 0:M.current)==null?void 0:W.input)==null?void 0:_.clientY)!=null?Q:P.current;V!==null&&(P.current=V);let O=N.data;v(O.dragType||null),D==="bottom"&&B&&N.data.id===t&&(L=null);let j=N.data.type==="editor"||N.data.type==="column-cell-item";if(B&&j)if(D==="top"){let F=s.current;if(F){let G=F.getBoundingClientRect(),ce=(re=V!=null?V:P.current)!=null?re:G.top+G.height/2,ge=G.top+G.height/2,fe=G.height,Ne=Math.max(10,Math.min(30,fe*.3));ce<ge-Ne?(g.current=!1,L="top"):g.current?L="bottom":L="top"}else g.current=!1,L="top"}else g.current?L="bottom":D==="bottom"&&(g.current=!0,L="bottom");else B&&!j&&(g.current=!1);if(!g.current&&(N.data.type==="editor"||N.data.type==="column-cell-item")&&typeof N.data.index=="number"){let F=N.data.index,G=x();((ee=G==null?void 0:G.index)!=null?ee:0)===F+1&&D==="top"&&(L=null)}L!==h.current&&(h.current=L,m(L))},onDrag:({self:E,source:N,location:M})=>{var W,_,Q,re,ee;if(E.data.disableDropIndicator){m(null);return}C.current&&(clearTimeout(C.current),C.current=null);let S=M.current.dropTargets;if(S.length>0&&S[0].element!==T){m(null);return}let D=(Q=(_=(W=M==null?void 0:M.current)==null?void 0:W.input)==null?void 0:_.clientY)!=null?Q:P.current;D!==null&&(P.current=D);let L=is(E.data),B=L,V=I(),O=N.data;v(O.dragType||null),L==="bottom"&&V&&N.data.id===t&&(B=null);let j=N.data.type==="editor"||N.data.type==="column-cell-item";if(V&&j)if(L==="top"){let F=s.current;if(F){let G=F.getBoundingClientRect(),ce=(re=D!=null?D:P.current)!=null?re:G.top+G.height/2,ge=G.top+G.height/2,fe=G.height,Ne=Math.max(10,Math.min(30,fe*.3));ce<ge-Ne?(g.current=!1,B="top"):g.current?B="bottom":B="top"}else g.current=!1,B="top"}else g.current?B="bottom":L==="bottom"&&(g.current=!0,B="bottom");else V&&!j&&(g.current=!1);if(!g.current&&(N.data.type==="editor"||N.data.type==="column-cell-item")&&typeof N.data.index=="number"){let F=N.data.index,G=x();((ee=G==null?void 0:G.index)!=null?ee:0)===F+1&&L==="top"&&(B=null)}B!==h.current&&(h.current=B,m(B))},onDragLeave:()=>{if(I()&&g.current){let E=T==null?void 0:T.getBoundingClientRect(),N=P.current;if(E&&N!==null&&N>=E.bottom-10)return;C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{g.current=!1,h.current=null,m(null),v(null),C.current=null},150)}else C.current&&(clearTimeout(C.current),C.current=null),g.current=!1,h.current=null,m(null),v(null)},onDrop:()=>{C.current&&(clearTimeout(C.current),C.current=null),g.current=!1,h.current=null,m(null),v(null)}}));return()=>{C.current&&(clearTimeout(C.current),C.current=null),w()}},[t,I,o,x]),(0,ut.jsx)(lv,{ref:s,id:t,fadeIn:A,className:r,dragging:u,closestEdge:f,dragType:p,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),lv=(0,Ve.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:s,id:l,editor:c,fadeIn:u,dragging:d,...f},m)=>{(0,Ve.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let p=(0,y5.useSetAtom)(Me),{resetButtonFormatting:v}=Sc(c),h=a((x,I)=>{let T=null;return x.doc.descendants((k,w)=>{var E;return T!==null?!1:((E=k.attrs)==null?void 0:E.id)===I?(T=w,!1):!0}),T},"findNodePositionById"),g=(0,Ve.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let x=h(c.state,l);return x===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(x),pos:x}},[c,l]),C=(0,Ve.useCallback)(()=>{c.commands.blur(),p(null)},[c,p]),P=(0,Ve.useCallback)(()=>{if(!(!c||!l))try{let{node:x,pos:I}=g();if(!x||I===null)return;let T=x.nodeSize,k=c.state.doc.childCount===1;p(null),c.commands.updateSelectionState(null);let w=c.state.tr;w.delete(I,I+T),w.setMeta("addToHistory",!0),c.view.dispatch(w),k&&setTimeout(()=>{let E=c.state.doc.nodeAt(0);if(E&&E.type.name==="paragraph"&&!E.attrs.id){let N=`node-${(0,v5.v4)()}`,M=c.state.tr;M.setNodeMarkup(0,void 0,{...E.attrs,id:N}),c.view.dispatch(M);let S=new CustomEvent("node-duplicated",{detail:{newNodeId:N}});document.dispatchEvent(S)}},50)}catch(x){console.error("Error deleting node:",x)}},[c,l,g,p]),y=(0,Ve.useCallback)(()=>{if(!(!c||!l))try{let{node:x,pos:I}=g();if(!x||I===null)return;if(x.type.name==="button"){v();return}let T=x.type.name==="blockquote";T||C(),setTimeout(()=>{let k=c.chain();if(k.setNodeSelection(I).unsetAllMarks(),T&&x.content&&x.content.firstChild?x.content.firstChild.type.name!=="paragraph"&&k.setParagraph():x.type.name!=="paragraph"&&!T&&k.setParagraph(),k.run(),T){let w=g();w.node&&w.pos!==null&&(p(w.node),c.commands.updateSelectionState(w.node))}},100)}catch(x){console.error("Error removing formatting:",x)}},[c,l,g,C,v,p]),b=(0,Ve.useCallback)(()=>{if(!(!c||!l))try{C(),setTimeout(()=>{let{node:x,pos:I}=g();if(!x||I===null)return;let T=x.type.name,k={...x.attrs};delete k.id;let w=I+(x==null?void 0:x.nodeSize);m5(c,T,w,k,E=>p(E),x.content)},100)}catch(x){console.error("Error duplicating node:",x)}},[c,l,g,C,p]),{node:A}=g();return(0,ut.jsxs)(b5.NodeViewWrapper,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:R("courier-flex courier-flex-col courier-relative draggable-item",t),...f,children:[i==="top"&&(0,ut.jsx)(Lc,{type:s}),(0,ut.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,ut.jsx)(g5,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,ut.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,ut.jsxs)("div",{"data-no-drag-preview":!0,className:R("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center",d&&"!courier-hidden"),children:[(A==null?void 0:A.type.name)!=="imageBlock"&&(A==null?void 0:A.type.name)!=="divider"&&(A==null?void 0:A.type.name)!=="spacer"&&(A==null?void 0:A.type.name)!=="button"&&(A==null?void 0:A.type.name)!=="column"&&(0,ut.jsxs)(ut.Fragment,{children:[(0,ut.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onMouseDown:x=>{x.preventDefault(),x.stopPropagation()},onClick:x=>{x.stopPropagation(),y()},tabIndex:-1,children:(0,ut.jsx)(Ed,{})}),(0,ut.jsx)(ye,{className:"courier-m-0"})]}),(0,ut.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onMouseDown:x=>{x.preventDefault(),x.stopPropagation()},onClick:x=>{x.stopPropagation(),b()},tabIndex:-1,children:(0,ut.jsx)(nd,{})}),(0,ut.jsx)(ye,{className:"courier-m-0"}),(0,ut.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onMouseDown:x=>{x.preventDefault(),x.stopPropagation()},onClick:x=>{x.stopPropagation(),P()},tabIndex:-1,children:(0,ut.jsx)(Wa,{})})]})]}),i==="bottom"&&(0,ut.jsx)(Lc,{type:s})]})});var Ni=require("react/jsx-runtime"),cv=a(({alignment:e,size:t,backgroundColor:r,textColor:o,borderWidth:n,borderRadius:i,borderColor:s,padding:l,fontWeight:c,fontStyle:u,children:d})=>(0,Ni.jsx)("div",{className:"courier-w-full node-element",children:(0,Ni.jsx)("div",{className:"courier-flex",style:{marginTop:`${l}px`,marginBottom:`${l}px`},children:(0,Ni.jsx)("div",{className:R("courier-inline-flex courier-justify-center courier-px-4 courier-py-2 courier-cursor-text courier-text-base",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e],t==="full"&&"courier-w-full"),style:{backgroundColor:r,color:o,borderWidth:`${n}px`,borderRadius:`${i}px`,borderColor:s,borderStyle:n>0?"solid":"none",caretColor:o,fontWeight:c,fontStyle:u},children:d})})}),"ButtonComponent"),w5=a(e=>{let t=(0,x5.useSetAtom)(ft),r=(0,T5.useCallback)(()=>{if(!e.editor.isEditable)return;let o=Lt(e);if(o){let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,Ni.jsx)(tr,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,Ni.jsx)(cv,{...e.node.attrs,children:(0,Ni.jsx)(C5.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var P5=require("uuid");var $e={label:"Button",link:"",alignment:"center",size:"default",backgroundColor:"#0085FF",textColor:"#ffffff",borderWidth:0,borderRadius:0,borderColor:"#000000",padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},Dl=Rc.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){St(this.editor,this.name)},addAttributes(){return{label:{default:$e.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:$e.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:$e.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},size:{default:$e.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},backgroundColor:{default:$e.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:$e.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderWidth:{default:$e.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:$e.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:$e.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:$e.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:$e.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:$e.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:$e.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:$e.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,P5.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Rc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,E5.ReactNodeViewRenderer)(w5)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var k5=require("uuid"),Ai=require("jotai"),qt=require("react");var Ca=a(({items:e,setItems:t,editor:r})=>{let[o]=(0,qt.useState)(null),[n,i]=(0,qt.useState)(null),[s,l]=(0,qt.useState)(null),[c]=(0,qt.useState)("outer"),u=(0,qt.useRef)([]),d=(0,qt.useRef)([]),f=(0,Ai.useAtomValue)(_e),m=(0,Ai.useSetAtom)(Cr),[p,v]=(0,Ai.useAtom)(se),h=(0,Ai.useAtomValue)(kn),g=r||f,C=(0,qt.useCallback)(()=>{if(!g)return;let I=g.getJSON(),T=Te(I),k=At(p,{channel:h,elements:T});v(k)},[g,h,p,v]),P=(0,qt.useCallback)(()=>{g==null||g.commands.removeDragPlaceholder(),t(I=>({...I,Editor:I.Editor.filter(T=>!T.toString().includes("_temp"))}))},[g==null?void 0:g.commands,t]),y=(0,qt.useCallback)(I=>{try{let T=g==null?void 0:g.state.doc;if(!T||I===0)return 0;if(I>=T.childCount)return T.content.size;let k=0;for(let w=0;w<Math.min(I,T.childCount);w++){let E=T.child(w);k+=E.nodeSize}return k}catch(T){return console.error("Error calculating document position:",T),0}},[g==null?void 0:g.state.doc]),b=(0,qt.useCallback)(I=>{let T={};switch(I){case"text":T=de;break;case"heading":T={};break;case"image":T=ht;break;case"button":T=$e;break;case"divider":T=Jr;break;case"spacer":T=Yl;break;case"customCode":T=un;break;case"column":T=$t;break}let w={type:I==="text"?"paragraph":I==="image"?"imageBlock":I==="spacer"?"divider":I,attrs:{...T,id:(0,k5.v4)()}};return I==="button"&&(w.content=[{type:"text",text:"Button"}]),w},[]),A=(0,qt.useCallback)((I,T)=>{if(!g)return;let{columnId:k,index:w,isEmpty:E}=T,N=null,M=0,S=-1;if(I.type==="sidebar"){if(!I.dragType)return;N=b(I.dragType)}else if(I.type==="editor"){if(g.state.doc.descendants((O,j)=>O.attrs.id===I.id?(S=j,N=O.toJSON(),M=O.nodeSize,!1):!0),S===-1){let O=e.Editor.findIndex(j=>j===I.id);if(O!==-1){S=y(O);let j=g.state.doc.nodeAt(S);j&&(N=j.toJSON(),M=j.nodeSize)}}if(S!==-1){let O=e.Editor.filter(j=>j!==I.id);O.length!==e.Editor.length&&t({...e,Editor:O})}}if(!N)return;let D=-1,L=null;if(g.state.doc.descendants((O,j)=>O.type.name==="column"&&O.attrs.id===k?(D=j,L=O,!1):!0),D===-1||!L)return;let B=L;S!==-1&&S<D&&(D-=M);let V=g.state.tr;if(S!==-1&&V.delete(S,S+M),E){let O=g.schema,j=Array.from({length:B.attrs.columnsCount},(_,Q)=>O.nodes.columnCell.create({index:Q,columnId:k,isEditorMode:!1},Q===w?[O.nodeFromJSON(N)]:[])),W=O.nodes.columnRow.create({},j);V.replaceWith(D+1,D+B.nodeSize-1,W)}else{let O=D+1;B.content.forEach(j=>{if(j.type.name==="columnRow"){let W=O+1;j.content.forEach((_,Q,re)=>{if(re===w){let ee=W+_.nodeSize-1;V.insert(ee,g.schema.nodeFromJSON(N))}W+=_.nodeSize})}O+=j.nodeSize})}g.view.dispatch(V),C()},[g,e,t,y,b,C]),x=(0,qt.useCallback)((I,T)=>{try{if(I.type==="sidebar"&&(T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")){let k=I.dragType;if(!k||!g)return;let w=T.insertPos;if(w===void 0)if(T.type==="editor"){let M=T.index+1;w=y(M)}else{console.warn("Nested drop without position data");return}let E=b(k);if(g.commands.insertContentAt(w,E),g.state.doc.resolve(w).depth===0){let M=g.state.doc.resolve(w).index(0),S=[...e.Editor];M<=S.length&&(S.splice(M,0,E.attrs.id),t({...e,Editor:S}))}C();return}if((I.type==="editor"||I.type==="column-cell-item"||I.type==="nested-drag")&&(T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")){if(!g)return;let k=-1,w=null;if(I.pos!==void 0&&(k=I.pos,w=g.state.doc.nodeAt(k)),(k===-1||!w)&&g.state.doc.descendants((S,D)=>S.attrs.id===I.id?(k=D,w=S,!1):!0),k===-1||!w){let S=e.Editor.findIndex(D=>D===I.id);S!==-1&&(k=y(S),w=g.state.doc.nodeAt(k))}if(!w||k===-1)return;let E=T.insertPos;if(E===void 0){let S;T.index===void 0?S=g.state.doc.childCount:T.index===-1?S=0:S=T.index+1,E=y(S)}if(E===void 0||E>k&&E<k+w.nodeSize)return;if(E>k){let S=E-w.nodeSize;g.chain().deleteRange({from:k,to:k+w.nodeSize}).insertContentAt(S,w.toJSON()).run()}else g.chain().insertContentAt(E,w.toJSON()).deleteRange({from:k+w.nodeSize,to:k+w.nodeSize*2}).run();let N=e.Editor.includes(I.id);if(N){let S=e.Editor.filter(D=>D!==I.id);t({...e,Editor:S})}let M=g.state.doc.resolve(E).depth===0;C()}}catch(k){console.error("[Pragmatic DnD] Error in handleDrop:",k)}},[e,g,t,y,C,b]);return(0,qt.useEffect)(()=>Gd({onDragStart:({source:I})=>{let T=I.data;m(!0),l(T.id),T.dragType&&i(T.dragType);let k=g==null?void 0:g.view.dom.querySelectorAll('[data-node-type="column"]');k&&(u.current=Array.from(k).map(E=>E.getBoundingClientRect()));let w=g==null?void 0:g.view.dom.querySelectorAll("[data-node-view-wrapper]");if(w){let E=new Set,N=Array.from(w).filter(M=>{let S=M,D=S.parentElement;if(D!=null&&D.hasAttribute("data-column-cell"))return!1;let L=S.getBoundingClientRect(),B=L.top+L.height/2;return E.has(Math.round(B))?!1:(E.add(Math.round(B)),!0)});d.current=N.map(M=>M.getBoundingClientRect())}},onDrop:({source:I,location:T})=>{let k=I.data,w=T.current.dropTargets[0];if(!w){P(),m(!1),l(null),i(null);return}let E=w.data;if(E.type==="column-cell"){A(k,E),m(!1),l(null),i(null),P();return}let N=E,M=is(w.data);if(N.pos!==void 0&&M&&g){let S=g.state.doc.nodeAt(N.pos);S&&(M==="top"?N.insertPos=N.pos:M==="bottom"&&(N.insertPos=N.pos+S.nodeSize))}if(N.insertPos===void 0&&M&&N.index!==void 0){let S=M==="top"?N.index-1:N.index;N={...N,index:S}}else if(N.index===void 0&&N.insertPos===void 0){let D=T.current.input.clientY;if(d.current.length>0){let L=0,B=1/0;d.current.forEach((_,Q)=>{let re=_.top+_.height/2,ee=Math.abs(D-re);ee<B&&(B=ee,L=Q)});let V=d.current[L],O=V.top+V.height/2,W=D>=O?L:L-1;N={...N,index:W,fromCoordinates:!0}}else N={...N,index:(g==null?void 0:g.state.doc.childCount)||0}}x(k,N),m(!1),l(null),i(null),P()}}),[g,m,P,l,i,x,A]),{activeId:s,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:P}},"usePragmaticDnd");var Dc=require("react");var M5=require("jotai");var Hc=a(({setItems:e,rafId:t,editor:r})=>{let o=(0,M5.useAtomValue)(_e),n=r||o,i=(0,Dc.useCallback)(s=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=s==null?void 0:s.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(f=>{let m=f,p=m.dataset.id;if(p){let v=m.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.parentElement}h||d.push(p)}}),e(f=>({Editor:d,Sidebar:f.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=s==null?void 0:s.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(f=>{let m=f,p=m.dataset.id;if(p){let v=m.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.parentElement}h||d.push(p)}}),e(f=>({Editor:d,Sidebar:f.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,Dc.useEffect)(()=>{if(!n||typeof n.on!="function")return;let s,l=a(()=>{n&&(s&&s(),s=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=a(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),s&&s(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var xa=require("react/jsx-runtime"),Rs=[{type:"text",align:"left",content:`
189
- `,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],uv=(0,De.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:s,dataMode:l,hidePreviewPanelExitButton:c,...u},d)=>{let f=(0,Ar.useAtomValue)(_e),[m,p]=(0,Ar.useAtom)(Me),[v,h]=(0,Ar.useAtom)(Yn),g=(0,De.useRef)({}),[C,P]=(0,De.useState)(c?"desktop":void 0),y=(0,Ar.useAtomValue)(Tt),b=(0,Ar.useAtomValue)(be),A=(0,Ar.useAtomValue)(xu),x=(0,Ar.useAtomValue)(_o),I=(0,De.useRef)(-1),T=(0,Ar.useSetAtom)(If),k=(0,De.useRef)(!1),w=(0,De.useRef)(!1),[E]=(0,Ar.useAtom)(se),N=(0,Ar.useAtomValue)(Co),M=(0,Ar.useAtomValue)(Ut),[S,D]=(0,De.useState)({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),L=(0,De.useRef)(null);Ca({items:S,setItems:D,editor:f});let{syncEditorItems:B}=Hc({setItems:D,rafId:L,editor:f});(0,De.useEffect)(()=>{M&&(w.current=!1)},[M]);let[V,O]=(0,De.useState)(!1);(0,De.useEffect)(()=>{if(b===!1||b===null){let F=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(F)}else O(!1)},[b,V]),(0,De.useEffect)(()=>{if(m){let F=m.type.name,G=ul(F);T({nodeName:F,config:G})}},[m,T]);let j=(0,De.useMemo)(()=>{var G,ce,ge,fe,Ne,mt,ue,Re,ke,nt,it,Yt,Xt,at,pt,yr,Qt,ie,vr,Xr,Qr,Fo,$n,jn,Zn,qn,Jn,H,Y,oe,Pe,ve,st,Nt;if(x)return x;let F=(ge=(ce=(G=y==null?void 0:y.data)==null?void 0:G.tenant)==null?void 0:ce.brand)==null?void 0:ge.settings;return{brandColor:((fe=F==null?void 0:F.colors)==null?void 0:fe.primary)||"#000000",textColor:((Ne=F==null?void 0:F.colors)==null?void 0:Ne.secondary)||"#000000",subtleColor:((mt=F==null?void 0:F.colors)==null?void 0:mt.tertiary)||"#666666",headerStyle:(Re=(ue=F==null?void 0:F.email)==null?void 0:ue.header)!=null&&Re.barColor?"border":"plain",logo:(it=(nt=(ke=F==null?void 0:F.email)==null?void 0:ke.header)==null?void 0:nt.logo)==null?void 0:it.image,link:(at=(Xt=(Yt=F==null?void 0:F.email)==null?void 0:Yt.header)==null?void 0:Xt.logo)==null?void 0:at.href,facebookLink:(ie=(Qt=(yr=(pt=F==null?void 0:F.email)==null?void 0:pt.footer)==null?void 0:yr.social)==null?void 0:Qt.facebook)==null?void 0:ie.url,linkedinLink:(Fo=(Qr=(Xr=(vr=F==null?void 0:F.email)==null?void 0:vr.footer)==null?void 0:Xr.social)==null?void 0:Qr.linkedin)==null?void 0:Fo.url,instagramLink:(qn=(Zn=(jn=($n=F==null?void 0:F.email)==null?void 0:$n.footer)==null?void 0:jn.social)==null?void 0:Zn.instagram)==null?void 0:qn.url,mediumLink:(oe=(Y=(H=(Jn=F==null?void 0:F.email)==null?void 0:Jn.footer)==null?void 0:H.social)==null?void 0:Y.medium)==null?void 0:oe.url,xLink:(Nt=(st=(ve=(Pe=F==null?void 0:F.email)==null?void 0:Pe.footer)==null?void 0:ve.social)==null?void 0:st.twitter)==null?void 0:Nt.url}},[x,y]),W=A&&!!j,_=(0,De.useCallback)(()=>{Object.values(g.current).forEach(F=>clearTimeout(F)),g.current={}},[]);(0,De.useEffect)(()=>()=>{_()},[_]),(0,De.useEffect)(()=>{let F=a(G=>{if(G.key==="Escape"&&(p(null),f==null||f.commands.blur(),I.current=-1),G.key==="Tab"&&f){G.preventDefault();let ce=-1;m&&f.state.doc.content.forEach((Ne,mt,ue)=>{m.attrs.id===Ne.attrs.id&&(ce=ue)}),ce===-1&&(ce=0);let ge=f.state.doc,fe;if(G.shiftKey?fe=(ce-1+ge.childCount)%ge.childCount:fe=(ce+1)%ge.childCount,fe!==ce||m===null){let Ne=ge.child(fe);p(Ne),f.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",F),()=>{document.removeEventListener("keydown",F)}},[f,m,p]),(0,De.useEffect)(()=>{if(b!==!1||M)return;let F=E!=null?E:"";if(F){let G=Lu(F,"email");h(G||"")}setTimeout(()=>{if(!(!f||f.isDestroyed)&&f.state.doc.childCount===1){let G=f.state.doc.child(0);p(G)}},0)},[y,b,M,f,h,p,E]),(0,De.useEffect)(()=>{b===!1&&y&&!w.current&&(w.current=!0,setTimeout(()=>{f&&!f.isDestroyed&&B(f)},300))},[b,y,f,B]),(0,De.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let Q=(0,De.useCallback)(F=>{let ce=F||(C===void 0?"desktop":void 0);P(ce),p(null),ce?f==null||f.setEditable(!1):f==null||f.setEditable(!0)},[f,C,P,p]),re=a(F=>{h(F.target.value)},"handleSubjectChange"),ee=(0,De.useMemo)(()=>{if(b!==!1||!V)return null;let F=s&&s.elements&&s.elements.length>0;F&&(w.current=!0);let G;return F&&(G=s.elements.find(ge=>ge.type==="channel"&&ge.channel==="email")),G||(G={type:"channel",channel:"email",elements:Rs}),Qe({version:"2022-01-01",elements:[G]},{channel:"email"})},[s,b,V]);return M&&(E===null||ee===null)?null:(0,xa.jsx)(Er,{theme:t,dataMode:l,isLoading:!!b,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,xa.jsx)(lo,{hidePublish:e,channels:r,routing:o}),...u,children:(0,xa.jsx)(xa.Fragment,{children:n==null?void 0:n({subject:v,handleSubjectChange:re,selectedNode:m,setSelectedNode:p,previewMode:C,templateEditor:f,ref:d,isBrandApply:W,brandSettings:j,items:S,content:ee,syncEditorItems:B,brandEditorContent:N,templateData:y,togglePreviewMode:Q,hidePreviewPanelExitButton:c})})})}),Bc=(0,De.memo)(uv);var Fc=class Fc{};a(Fc,"UploadImageAPI"),Fc.uploadImage=a(async t=>new Promise((r,o)=>{let n=new FileReader;n.onload=()=>{typeof n.result=="string"?r(n.result):o(new Error("Failed to convert image to data URL"))},n.onerror=()=>{o(new Error("Failed to read image file"))},n.readAsDataURL(t)}),"uploadImage");var Jm=Fc,Gm=Jm;var Sr=a(e=>[am,Zm.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1}),pm.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Um.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),Fg,im,mm,Yd,lm.configure({levels:[1,2,3,4,5,6]}),Dl,Vl,Wm.Color,Ul,_l,ql,Gl,um.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),jm.Underline,cc.configure(),Ql.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await Gm.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await Gm.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),_m.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),$m.Typography,zm.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),Kd.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Fm.configure({variables:e==null?void 0:e.variables,disableSuggestions:e==null?void 0:e.disableVariableAutocomplete}),Bm,Vm,Om,tc,nc],"ExtensionKit");var _c=require("@tiptap/react");var N5=require("jotai"),Si=require("react");var Vc=a(e=>{let t=(0,N5.useAtomValue)(Me),[r,o]=(0,Si.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Si.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,Si.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,Si.useCallback)(({editor:s})=>{let l=["paragraph","heading","blockquote"],{$head:c,$anchor:u}=s.state.selection,d=c.node();if(l.includes(d.type.name)&&d.attrs.isSelected)return!0;for(let f=1;f<=c.depth;f++){let m=c.node(f);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let p=s.isFocused&&(c.pos!==u.pos||s.state.selection.from!==s.state.selection.to),v=s.isFocused;return p||v}}return!1},[]),...r}},"useTextmenuStates");var Uc=require("jotai"),ot=require("lucide-react"),Lr=require("react");var Oc=require("react");var S5=Ae(require("@tippyjs/react"),1),I5=require("react");var pr=require("react/jsx-runtime"),A5=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,dv=a(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-neutral-500 courier-border-b-2";return e==="Mod"?(0,pr.jsx)("kbd",{className:t,children:A5?"\u2318":"Ctrl"}):e==="Shift"?(0,pr.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,pr.jsx)("kbd",{className:t,children:A5?"\u2325":"Alt"}):(0,pr.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),L5=a(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=(0,I5.useCallback)(s=>(0,pr.jsxs)("span",{className:"courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-white courier-border courier-border-neutral-100 courier-rounded-lg courier-shadow-sm courier-z-[999]",tabIndex:-1,"data-placement":s["data-placement"],"data-reference-hidden":s["data-reference-hidden"],"data-escaped":s["data-escaped"],children:[r&&(0,pr.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-neutral-500",children:r}),o&&(0,pr.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(l=>(0,pr.jsx)(dv,{children:l},l))})]}),[o,r]);return t?(0,pr.jsx)(S5.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:i,animation:!1,children:(0,pr.jsx)("span",{children:e})}):(0,pr.jsx)(pr.Fragment,{children:e})},"Tooltip");var Ds=require("react/jsx-runtime"),R5=(0,Oc.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let s=R("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Ds.jsx)(Hm,{className:s,...n,ref:i,children:t})});R5.displayName="Toolbar";var D5=(0,Oc.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=R("courier-bg-neutral-200 dark:courier-bg-neutral-800",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Ds.jsx)("div",{className:n,ref:o,...r})});D5.displayName="Toolbar.Divider";var H5=(0,Oc.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...s},l)=>{let c=R("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=(0,Ds.jsx)(Oe,{className:c,variant:r,buttonSize:t,ref:l,...s,children:e});return n?(0,Ds.jsx)(L5,{title:n,shortcut:i,children:u}):u});H5.displayName="ToolbarButton";var Wc={Wrapper:R5,Divider:D5,Button:H5};var B5=require("lucide-react"),F5=require("react");var Ir=require("react/jsx-runtime"),mv=a(e=>e.type==="option","isOption"),V5=a(({options:e,containerRef:t})=>{let r=(0,F5.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,Ir.jsxs)(Ys,{children:[(0,Ir.jsx)(Xs,{asChild:!0,children:(0,Ir.jsxs)(Oe,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,Ir.jsx)(B5.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,Ir.jsx)(Ha,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(mv(o))return(0,Ir.jsx)(Ba,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,Ir.jsx)(Ir.Fragment,{children:o.id==="heading1"?(0,Ir.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,Ir.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,Ir.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var O5=require("@tiptap/react");var W5=a(e=>(0,O5.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var Mt=require("react/jsx-runtime"),pv=(0,Lr.memo)(Wc.Button),fv=(0,Lr.memo)(V5),zc=a(({editor:e,config:t})=>{var I;let r=Sc(e),o=Vc(e),n=W5(e),i=(0,Lr.useRef)(null),s=(0,Uc.useAtomValue)(dl),l=(0,Uc.useAtomValue)(Me),c=l==null?void 0:l.type.name,u=(0,Uc.useAtomValue)(Sf),[d,f]=(0,Lr.useState)(()=>{let{selection:T}=e.state;return{from:T.from,to:T.to,empty:T.empty}});(0,Lr.useEffect)(()=>{let T=a(()=>{let{selection:k}=e.state;f({from:k.from,to:k.to,empty:k.empty})},"updateSelection");return e.on("selectionUpdate",T),e.on("transaction",T),()=>{e.off("selectionUpdate",T),e.off("transaction",T)}},[e]);let m=(0,Lr.useMemo)(()=>!d.empty&&d.from!==d.to,[d]),p=(0,Lr.useMemo)(()=>t||u(c||"",m),[t,u,c,m]),v=a(()=>{let{selection:T}=e.state;if(!(T.empty&&!o.isLink&&!e.can().setLink({href:""})))if(o.isLink){let k=e.state.tr.setMeta("showLinkForm",{from:T.from,to:T.to});e.view.dispatch(k)}else{let k=e.state.tr.setMeta("showLinkForm",{from:T.from,to:T.to});e.view.dispatch(k)}},"handleLinkToggle"),h=a(()=>{if(s.ref){let N=s.ref,M=N.value,S=s.caretPosition||N.selectionStart||0,D=M.substring(0,S),L=M.substring(S),B=`${D}{{${L}`,V=S+2;N.focus();let O=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(O,"target",{writable:!1,value:{...N,value:B}}),N.value=B,N.dispatchEvent(O),N.setSelectionRange(V,V),N.getBoundingClientRect()){let W=B.slice(0,V),_=document.createElement("span");_.style.font=window.getComputedStyle(N).font,_.style.whiteSpace="pre-wrap",_.textContent=W,document.body.appendChild(_);let Q=_.offsetWidth;document.body.removeChild(_);let re=parseInt(window.getComputedStyle(N).lineHeight),ee=W.split(`
190
- `).length-1,F=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(Q%N.offsetWidth,N.offsetWidth-200),top:ee*re+30}},bubbles:!0});N.dispatchEvent(F)}return}let{state:T,dispatch:k}=e.view,{tr:w}=T;w.insertText("{{"),k(w),e.commands.focus();let E=e.state.tr.setMeta("showVariableSuggestions",{from:e.state.selection.from,to:e.state.selection.to});e.view.dispatch(E)},"handleVariableClick"),g=a((T,k,w,E,N,M,S)=>{let D=p[T];return!D||D.state==="hidden"?null:(0,Mt.jsx)(pv,{tooltip:w,tooltipShortcut:M,onClick:E,active:N,disabled:D.state==="disabled",...S,children:k},T)},"renderButton"),C=a((T,k)=>{let w=T.filter(E=>!!E);return w.length>0?(0,Mt.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:w},k):null},"renderGroup"),P=C([((I=p.contentType)==null?void 0:I.state)==="enabled"&&(0,Mt.jsx)(fv,{options:n,containerRef:i},"content-type")],"content-type-group"),y=C([g("bold",(0,Mt.jsx)(ot.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",r.onBold,o.isBold,["Mod","B"]),g("italic",(0,Mt.jsx)(ot.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",r.onItalic,o.isItalic,["Mod","I"]),g("underline",(0,Mt.jsx)(ot.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",r.onUnderline,o.isUnderline,["Mod","U"]),g("strike",(0,Mt.jsx)(ot.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",r.onStrike,o.isStrike,["Mod","Shift","S"])],"text-style-group"),b=C([g("alignLeft",(0,Mt.jsx)(ot.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",r.onAlignLeft,o.isAlignLeft,["Shift","Mod","L"]),g("alignCenter",(0,Mt.jsx)(ot.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",r.onAlignCenter,o.isAlignCenter,["Shift","Mod","E"]),g("alignRight",(0,Mt.jsx)(ot.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",r.onAlignRight,o.isAlignRight,["Shift","Mod","R"]),g("alignJustify",(0,Mt.jsx)(ot.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",r.onAlignJustify,o.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),A=C([g("quote",(0,Mt.jsx)(ot.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",r.onQuote,o.isQuote,["Mod","Shift","B"])],"block-style-group"),x=C([g("link",(0,Mt.jsx)(ot.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,o.isLink,["Mod","K"]),g("variable",(0,Mt.jsx)(ot.Braces,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,Mt.jsx)(Wc.Wrapper,{ref:i,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[P,y,b,A,x].filter(Boolean).map((T,k)=>(0,Mt.jsxs)(Lr.Fragment,{children:[T,k<[P,y,b,A,x].filter(Boolean).length-1&&(0,Mt.jsx)(Wc.Divider,{})]},`item-${k}`))})},"TextMenu");var Km=require("react/jsx-runtime"),Rr=a(({config:e})=>{let{editor:t}=(0,_c.useCurrentEditor)(),r=Vc(t);return t?(0,Km.jsx)(_c.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var s,l,c,u;let o=(c=(l=(s=t==null?void 0:t.state)==null?void 0:s.selection)==null?void 0:l.from)!=null?c:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,Km.jsx)(zc,{editor:t,config:e})}):null},"BubbleTextMenu");var U5=require("@tiptap/pm/state"),Ta=require("@tiptap/react"),Hs=require("jotai"),co=require("react");var Jt=require("react/jsx-runtime"),gv=a(({value:e,readOnly:t})=>{let{editor:r}=(0,Ta.useCurrentEditor)(),o=(0,Hs.useSetAtom)(Oi),n=(0,Hs.useAtomValue)(be),i=(0,co.useRef)(!1);return(0,co.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Su(e!=null?e:"")))},[r,e,n,t]),(0,co.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),hv=a(({variables:e,facebookLink:t,linkedinLink:r,instagramLink:o,mediumLink:n,xLink:i,readOnly:s=!1,value:l,onUpdate:c})=>{let d=(0,co.useRef)(!1),f=(0,Hs.useSetAtom)(Me),m=(0,co.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...e}),[e]),p=Ta.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:h})=>{let{state:g,dispatch:C}=h.view;return C(g.tr.setSelection(U5.TextSelection.create(g.doc,g.selection.$anchor.pos))),f&&f(null),!1}}}});(0,co.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let v=(0,co.useMemo)(()=>[...Sr({variables:m,setSelectedNode:f,disableVariableAutocomplete:!0}),p].filter(h=>h!==void 0),[p,m,f,!0]);return(0,Jt.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,Jt.jsxs)(Ta.EditorProvider,{content:Su(l!=null?l:""),extensions:v,editable:!s,autofocus:!s,onUpdate:c,editorContainerProps:{className:R("courier-py-2 courier-flex-grow",s&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,Jt.jsx)(gv,{value:l,readOnly:s}),(0,Jt.jsx)(Rr,{})]}),(0,Jt.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[t&&(0,Jt.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(za,{className:"courier-w-5 courier-h-5"})}),r&&(0,Jt.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(ja,{className:"courier-w-5 courier-h-5"})}),o&&(0,Jt.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)($a,{className:"courier-w-5 courier-h-5"})}),n&&(0,Jt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(Za,{className:"courier-w-5 courier-h-5"})}),i&&(0,Jt.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(Ka,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),wa=(0,co.memo)(hv);var Dr=require("react/jsx-runtime"),z5=a(({value:e,icon:t,...r})=>(0,Dr.jsx)(tt,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),$c=a(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,Dr.jsxs)("div",{...n,className:R("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",n.className),children:[e&&!r&&(0,Dr.jsxs)(Dr.Fragment,{children:[(0,Dr.jsxs)(er,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,Dr.jsx)(z5,{value:"desktop",icon:(0,Dr.jsx)(rd,{})}),(0,Dr.jsx)(z5,{value:"mobile",icon:(0,Dr.jsx)(bd,{})})]}),!o&&(0,Dr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,Dr.jsxs)(Oe,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var Xm=require("react");function bv(){typeof window!="undefined"&&(window.__COURIER_CREATE_TEST__||(window.__COURIER_CREATE_TEST__={editors:{email:null,sms:null,push:null,inbox:null,slack:null,teams:null},currentEditor:null,activeChannel:null,templateEditorContent:null}))}a(bv,"initTestHelpers");function Hr(e,t){typeof window!="undefined"&&(bv(),window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.editors[e]=t,window.__COURIER_CREATE_TEST__.currentEditor=t,window.__COURIER_CREATE_TEST__.activeChannel=t?e:null))}a(Hr,"setTestEditor");var j5=require("@tiptap/core"),Z5=require("@tiptap/pm/state"),jc=require("@tiptap/react"),dt=require("jotai"),Ee=require("react");var _5=require("@tiptap/react"),$5=require("react");var uo=a(({value:e,defaultValue:t})=>{let{editor:r}=(0,_5.useCurrentEditor)();return(0,$5.useEffect)(()=>{r&&r.commands.setContent(e||t)},[r,e,t]),null},"ReadOnlyEditorContent");var Jo=require("react/jsx-runtime"),yv=a(({value:e})=>{let{editor:t}=(0,jc.useCurrentEditor)(),[r,o]=(0,dt.useAtom)(se),n=(0,dt.useSetAtom)(wt),i=(0,dt.useAtomValue)(Yn),s=(0,dt.useAtomValue)(Me),l=(0,dt.useSetAtom)(_e),c=(0,dt.useSetAtom)(Qn),u=(0,Ee.useRef)(!1),d=(0,Ee.useRef)(),f=(0,dt.useAtomValue)(be),m=(0,dt.useAtomValue)(Tt),p=(0,Ee.useRef)(!1),v=(0,dt.useAtomValue)(Ut);return(0,Ee.useEffect)(()=>{f&&(p.current=!1)},[f]),(0,Ee.useEffect)(()=>(c({action:"register",id:"email-subject",fn:a(()=>{var g;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&f===!1&&!v))try{let C=Te(t.getJSON());if(!C||!Array.isArray(C))return;let P=i;if(!i&&r){let x=(g=r==null?void 0:r.elements)==null?void 0:g.find(I=>I.type==="channel"&&I.channel==="email");x&&(P=Da(x,"email"))}let y=bo(r,"email",P||"",C),b={elements:y.elements,channel:"email",...y.raw&&{raw:y.raw}},A=At(r,b);JSON.stringify(r)!==JSON.stringify(A)&&(o(A),n(A))}catch(C){console.error("[FlushSubjectUpdate]",C)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,f,v,r,o,n,c]),(0,Ee.useEffect)(()=>{!t||f!==!1||p.current||!e||(l(t),p.current=!0,t.commands.setContent(e))},[t,e,l,f]),(0,Ee.useEffect)(()=>{if(!(!(t&&i!==null)||f!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let g=Te(t.getJSON());if(!g||!Array.isArray(g))return;let C=i;if(!i&&r){let A=(h=r==null?void 0:r.elements)==null?void 0:h.find(x=>x.type==="channel"&&x.channel==="email");A&&(C=Da(A,"email"))}let P=bo(r,"email",C||"",g),y={elements:P.elements,channel:"email",...P.raw&&{raw:P.raw}},b=At(r,y);JSON.stringify(r)!==JSON.stringify(b)&&(o(b),n(b))}catch(g){console.error(g)}},500),()=>{d.current&&clearTimeout(d.current)}},[m,t,i,o,n,f,r,v]),(0,Ee.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,Ee.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(s)},[t,s]),(0,Ee.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),vv=a(({value:e,readOnly:t=!1,variables:r,onDestroy:o,onUpdate:n,subject:i})=>{let l=(0,dt.useSetAtom)(ml),c=(0,Ee.useRef)(),[u,d]=(0,dt.useAtom)(se),f=(0,dt.useAtomValue)(Yn),m=i!=null?i:f,p=(0,dt.useSetAtom)(Me),v=(0,dt.useAtomValue)(_e),h=(0,dt.useAtomValue)(Ut),g=(0,dt.useAtomValue)(Cr),C=(0,dt.useSetAtom)(Qn),P=(0,dt.useSetAtom)(wt),y=(0,Ee.useRef)(u),b=(0,Ee.useRef)(m),A=(0,Ee.useRef)(g);(0,Ee.useEffect)(()=>{y.current=u},[u]),(0,Ee.useEffect)(()=>{b.current=m},[m]),(0,Ee.useEffect)(()=>{A.current=g},[g]),(0,Ee.useEffect)(()=>{v==null||v.setEditable(!t)},[t,v]);let x=j5.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:W})=>{let{state:_,dispatch:Q}=W.view;return Q(_.tr.setSelection(Z5.TextSelection.create(_.doc,_.selection.$anchor.pos))),p&&p(null),!1}}}}),I=(0,Ee.useCallback)(({editor:W})=>{n==null||n(W),Hr("email",W),p&&setTimeout(()=>{p(null)},100)},[p,n]),T=(0,Ee.useRef)(),k=(0,Ee.useRef)(null),w=(0,Ee.useCallback)((W,_)=>{var ge;if(h)return;let Q=y.current,re=b.current;if(!Q){let fe={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:_}]};d(fe),P(fe);return}let ee=Q.elements.find(fe=>fe.type==="channel"&&fe.channel==="email"),F={...ee};F.elements=(ge=F.elements)==null?void 0:ge.filter(fe=>fe.type!=="meta");let G={type:"channel",channel:"email",elements:_};if(JSON.stringify(F)!==JSON.stringify(G)){let fe=re;!re&&ee&&(fe=Da(ee,"email"));let Ne=bo(Q,"email",fe||"",_);G.elements=Ne.elements,Ne.raw&&(G.raw=Ne.raw);let mt=At(Q,G);d(mt),P(mt)}n==null||n(W),Hr("email",W)},[d,P,n,h]),E=(0,Ee.useCallback)(({editor:W})=>{let _=Te(W.getJSON());k.current={editor:W,elemental:_},T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{if(k.current){let{editor:Q,elemental:re}=k.current;w(Q,re),k.current=null}},200)},[w]),N=(0,Ee.useCallback)(({editor:W})=>{if(A.current)return;let{selection:_}=W.state,{$anchor:Q}=_,ee=_.$head.marks().find(ge=>ge.type.name==="link");ee||W.isActive("link")?l({mark:ee}):l(null);let F=Q.depth,G=null,ce=null;for(;F>0;){let ge=Q.node(F);!ce&&ge.type.name==="blockquote"&&(ce=ge),!G&&(ge.type.name==="paragraph"||ge.type.name==="heading")&&(G=ge),F--}ce?p(ce):G&&p(G)},[l,p]),M=(0,Ee.useCallback)(({editor:W,transaction:_})=>{let Q=_==null?void 0:_.getMeta("showLinkForm");if(Q){let{selection:re}=W.state,F=re.$head.marks().find(G=>G.type.name==="link");l({mark:F,link:{from:Q.from,to:Q.to}})}},[l]),S=(0,Ee.useCallback)(()=>{c.current&&clearTimeout(c.current),T.current&&clearTimeout(T.current),o==null||o(),Hr("email",null)},[o]);(0,Ee.useEffect)(()=>(C({action:"register",id:"email-content",fn:a(()=>{if(T.current&&(clearTimeout(T.current),T.current=void 0,k.current)){let{editor:_,elemental:Q}=k.current;w(_,Q),k.current=null}},"flushContentUpdate")}),()=>{C({action:"unregister",id:"email-content"})}),[w,C]);let D=(0,Ee.useCallback)(W=>{var F;if(A.current)return;let _=(F=W.view)==null?void 0:F.editor;if(!_||!_.isEditable)return;let Q=W.target,re=_.view.posAtDOM(Q,0),ee=_.state.doc.resolve(re).node();ee.type.name==="paragraph"&&p(ee)},[p]),L=(0,Ee.useCallback)(()=>!A.current,[]),B=(0,Ee.useMemo)(()=>[...Sr({variables:r,setSelectedNode:p,shouldHandleClick:L,disableVariableAutocomplete:!0}),x].filter(W=>W!==void 0),[x,r,p,L,!0]),V=e||{type:"doc",content:[{type:"paragraph"}]},O=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:I,onUpdate:E,onSelectionUpdate:N,onTransaction:M},j=(0,Ee.useRef)(null);return(0,Ee.useEffect)(()=>{let W=j.current;if(!(!W||t))return _r({element:W,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:_})=>_.data.type==="sidebar"?!0:_.data.type==="editor"})},[t]),(0,Jo.jsx)("div",{ref:j,children:(0,Jo.jsx)(jc.EditorProvider,{content:V,extensions:B,...O,onDestroy:S,editorContainerProps:{onClick:D},"data-testid":"editor-provider",immediatelyRender:!1,children:t?(0,Jo.jsx)(uo,{value:V,defaultValue:Rs}):(0,Jo.jsxs)(Jo.Fragment,{children:[(0,Jo.jsx)(yv,{value:V}),(0,Jo.jsx)(Rr,{})]})})})},"EmailEditor"),Zc=vv;var Bs=require("jotai"),q5=require("lucide-react");var Wn=require("react");var qc=require("react/jsx-runtime"),Ea=a(({children:e,id:t,className:r,editor:o})=>(0,qc.jsx)(Cv,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),Cv=(0,Wn.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,Wn.useRef)(null),[s,l]=(0,Wn.useState)(!1);return(0,Wn.useEffect)(()=>{let c=i.current;if(!(!c||!r))return $o(ns({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,qc.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:R(t,"courier-relative",s&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,qc.jsx)("div",{children:e})})});var He=require("react/jsx-runtime"),Jc=a(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=(0,Bs.useAtomValue)(Tt),i=(0,Bs.useSetAtom)(ta),s=(0,Bs.useAtomValue)(Ot);return(0,He.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,He.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,He.jsxs)(He.Fragment,{children:[(0,He.jsx)("p",{children:r}),(0,He.jsx)(ye,{className:"courier-my-4"})]}),(0,He.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>(0,He.jsx)(Ea,{id:u.toString(),editor:o,children:(0,He.jsxs)("div",{className:R("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,He.jsx)(q5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),u==="heading"&&(0,He.jsx)(kl,{draggable:!0}),u==="text"&&(0,He.jsx)(Ln,{draggable:!0}),u==="image"&&(0,He.jsx)(Ml,{draggable:!0}),u==="spacer"&&(0,He.jsx)(Nl,{draggable:!0}),u==="divider"&&(0,He.jsx)(In,{draggable:!0}),u==="button"&&(0,He.jsx)(Sn,{draggable:!0}),u==="customCode"&&(0,He.jsx)(ds,{draggable:!0}),u==="column"&&(0,He.jsx)(Pl,{draggable:!0})]})},u))})]}),t&&(0,He.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,He.jsx)(ye,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?(0,He.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,He.jsx)(Oe,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!s,children:"Edit brand"})}):(0,He.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,He.jsx)("h3",{className:"courier-text-md courier-font-medium",children:"Customize brand theme"}),(0,He.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,He.jsx)(Oe,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var J5=require("jotai");var Ao=require("react/jsx-runtime"),Gc=a(({element:e,editor:t})=>{var i,s;let r=(0,J5.useAtomValue)(Bd);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((s=e.marks)!=null&&s.some(l=>l.type.name==="link")))return(0,Ao.jsx)(ch,{editor:t,mark:r==null?void 0:r.mark,pendingLink:r==null?void 0:r.link});let o=t==null?void 0:t.isActive("blockquote"),n=a(()=>{if(!t)return;let{$anchor:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Ao.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Ao.jsx)(q1,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Ao.jsx)(Sg,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Ao.jsx)(Jg,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Ao.jsx)(nh,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Ao.jsx)(nm,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Ao.jsx)(z1,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Ao.jsx)(tm,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var Ym=require("react"),G5=require("jotai");var hn=require("react/jsx-runtime"),Un=(0,Ym.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,hn.jsx)("div",{className:R("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),zn=(0,Ym.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},s)=>{let[l,c]=(0,G5.useAtom)(Wo),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,hn.jsxs)(hn.Fragment,{children:[u&&(0,hn.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),(0,hn.jsx)("div",{className:R("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,hn.jsx)("div",{className:R("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto courier-bg-white","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":d+" courier-translate-x-0"),...i,ref:s,children:e})})]})});var Fs=require("jotai");var Ye=require("react/jsx-runtime"),Qm=(0,Xm.forwardRef)(({children:e,className:t,...r},o)=>(0,Ye.jsx)("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),ep=(0,Xm.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,Ye.jsx)("div",{className:R("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),K5=a(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:s,dataMode:l,...c})=>{let u=(0,Fs.useAtomValue)(se),d=(0,Fs.useAtomValue)(Wo),f=(0,Fs.useSetAtom)(Wo),m=a(()=>{d&&f(!1)},"handleSubjectAreaClick");return(0,Ye.jsx)(Bc,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:s,dataMode:l,render:({subject:p,handleSubjectChange:v,selectedNode:h,setSelectedNode:g,previewMode:C,templateEditor:P,ref:y,isBrandApply:b,brandSettings:A,items:x,content:I,syncEditorItems:T,brandEditorContent:k,templateData:w,togglePreviewMode:E,hidePreviewPanelExitButton:N})=>{var M,S,D,L,B,V;return(0,Ye.jsxs)(Un,{previewMode:C,children:[(0,Ye.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,Ye.jsxs)("div",{className:"courier-bg-primary courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:m,children:[(0,Ye.jsx)("h4",{className:"courier-text-sm",children:"Subject: "}),(0,Ye.jsx)(pe,{value:p!=null?p:"",onChange:v,onFocus:()=>g(null),className:"!courier-bg-background read-only:courier-cursor-default read-only:courier-border-transparent md:courier-text-md courier-py-1 courier-border-transparent !courier-border-none courier-font-medium",placeholder:"Write subject...",readOnly:C!==void 0})]}),(0,Ye.jsxs)(Qm,{ref:y,children:[(0,Ye.jsxs)(ep,{previewMode:C,children:[b&&(0,Ye.jsxs)("div",{className:R("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(A==null?void 0:A.headerStyle)==="border"&&"courier-pt-6"),children:[(A==null?void 0:A.headerStyle)==="border"&&(0,Ye.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:A==null?void 0:A.brandColor}}),(A==null?void 0:A.logo)&&(0,Ye.jsx)("img",{src:A.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),I&&(0,Ye.jsx)(Zc,{value:I,onUpdate:T,variables:e}),b&&w&&(0,Ye.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,Ye.jsx)(wa,{readOnly:!0,value:k!=null?k:(V=(B=(L=(D=(S=(M=w==null?void 0:w.data)==null?void 0:M.tenant)==null?void 0:S.brand)==null?void 0:D.settings)==null?void 0:L.email)==null?void 0:B.footer)==null?void 0:V.markdown,variables:e,facebookLink:A==null?void 0:A.facebookLink,linkedinLink:A==null?void 0:A.linkedinLink,instagramLink:A==null?void 0:A.instagramLink,mediumLink:A==null?void 0:A.mediumLink,xLink:A==null?void 0:A.xLink})})]}),(0,Ye.jsx)($c,{previewMode:C,togglePreviewMode:E,hideExitButton:N})]})]}),(0,Ye.jsx)(zn,{previewMode:C,children:(0,Ye.jsx)("div",{className:"courier-p-1 courier-h-full",children:h?(0,Ye.jsx)(Gc,{element:h,editor:P}):(0,Ye.jsx)(Jc,{items:x.Sidebar,brandEditor:i,label:"Blocks library",editor:P!=null?P:void 0})})})]})},...c})},"EmailLayout");var Y5=require("@tiptap/react"),So=require("jotai"),vt=require("react");var tp=require("react/jsx-runtime"),Vs=[{type:"text",content:`
167
+ `,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(m.errors)throw new Error(m.errors.map(y=>y.message).join(`
168
+ `));let p=m.data;return(d=(u=(c=p==null?void 0:p.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:d.url}catch(f){throw console.error("Error uploading image:",f),f}},"uploadImage");function Bi(){let[e]=(0,Tu.useAtom)(ar),[t]=(0,Tu.useAtom)(sr),r=lp();return{uploadImage:(0,wp.useCallback)(async n=>{if(typeof r=="function"){let i,s;try{i=await r(n),i===void 0&&(i=await r(n.file))}catch(u){s=u;try{i=await r(n.file)}catch{throw s}}let l="",c;if(typeof i=="string")l=i;else if(i){c=i==null?void 0:i.message;let u=i.url;typeof u=="string"?l=u:u&&typeof u=="object"&&(c=c||(u==null?void 0:u.message))}if(c)throw new Error(c);if(!l)throw s||new Error("Error uploading image");return{url:l}}else{if(!e||!t)throw new Error("Upload failed: Missing configuration for image upload");let i=n.file instanceof File?n.file:new File([n.file],"upload",{type:n.file.type}),s=await Tp(i,{apiUrl:e,token:t});if(!s)throw new Error("Upload failed: No URL returned from server");return{url:s}}},[e,t,r])}}a(Bi,"useImageUpload");var Ap=require("clsx"),Np=require("tailwind-merge");var Or=require("uuid");function cr(e){let t=e.trim();if(!t||t.startsWith(".")||t.endsWith(".")||t.includes("..")||t.includes(" "))return!1;let r=t.split("."),o=/^[a-zA-Z_][a-zA-Z0-9_]*$/;for(let n of r)if(!n||!o.test(n))return!1;return!0}a(cr,"isValidVariableName");var u2="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function _s(e){return e?e===u2:!0}a(_s,"isBlankImageSrc");var $s=a((e,t)=>new Promise(r=>{let o=new FileReader;o.onload=n=>{var s;let i=new Image;i.onload=()=>{var f;let l,c;i.width>i.height?(l=Math.min(t,i.width),c=Math.round(i.height/i.width*l)):(c=Math.min(t,i.height),l=Math.round(i.width/i.height*c));let u=document.createElement("canvas");u.width=l,u.height=c;let d=u.getContext("2d");if(d){d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(i,0,0,l,c);let m=.8,p=u.toDataURL(e.type||"image/jpeg",m),y=0,h=5;for(;p.length>512e3&&y<h;)y++,m-=.1,m<.3&&(m=.3),p=u.toDataURL(e.type||"image/jpeg",m);r({dataUrl:p,width:l,height:c})}else r({dataUrl:(f=n.target)==null?void 0:f.result,width:i.width,height:i.height})},i.src=(s=n.target)==null?void 0:s.result},o.readAsDataURL(e)}),"resizeImage");function Ep(e){let t=[],r=e.replace(/\n$/,"").split(`
169
+ `);for(let o=0;o<r.length;o++)d2(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}a(Ep,"parseMDContent");function d2(e,t){m2(e,t)}a(d2,"parseTextLine");function Pp(e,t){t.length!==0&&e.forEach(r=>{r.marks=r.marks||[],t.forEach(o=>{var n,i;(n=r.marks)!=null&&n.some(s=>s.type===o.type)||(i=r.marks)==null||i.push({type:o.type,...o.href&&{attrs:{href:o.href}}})}),r.marks.length===0&&delete r.marks})}a(Pp,"applyMarks");function m2(e,t){if(!e)return;let r=[],o=/\[([^\]]+)\]\(([^)]+)\)/g,n,i=0;for(;(n=o.exec(e))!==null;)n.index>i&&r.push({type:"text",text:e.substring(i,n.index),start:i,end:n.index}),r.push({type:"link",text:n[1],start:n.index,end:n.index+n[1].length,attrs:{href:n[2]}}),i=n.index+n[0].length;i<e.length&&r.push({type:"text",text:e.substring(i),start:i,end:e.length});let s=[];for(let u of r){if(u.type==="link"){s.push(u);continue}let d=0,f=/(\*\*|\*|__|_|~|\+|\{\{[^}]+\}\}|\{\}[^{}]+\{\})/g,m=u.text,p;for(;(p=f.exec(m))!==null;){let y=p.index,h=p[0],v=y+h.length;if(y>d&&s.push({type:"text",text:m.substring(d,y),start:u.start+d,end:u.start+y}),h.startsWith("{{")||h.startsWith("{}")){let C=h.startsWith("{{")?h.slice(2,-2).trim():h.substring(2,h.length-2).trim();cr(C)?s.push({type:"variable",text:h,start:u.start+y,end:u.start+v,attrs:{id:C}}):s.push({type:"text",text:h,start:u.start+y,end:u.start+v})}else s.push({type:"marker",text:h,start:u.start+y,end:u.start+v});d=v}d<m.length&&s.push({type:"text",text:m.substring(d),start:u.start+d,end:u.start+m.length})}s.sort((u,d)=>u.start-d.start);let l=[],c=[];for(let u of s)if(u.type==="text"){let d=[];wu(u.text,[],d),Pp(d,l),c.push(...d)}else if(u.type==="variable"){let d={type:"variable",attrs:u.attrs};Pp([d],l),c.push(d)}else if(u.type==="link"){let d=[];wu(u.text,[],d),d.forEach(f=>{var m;f.marks=f.marks||[],f.marks.push({type:"link",attrs:{href:(m=u.attrs)==null?void 0:m.href}})}),c.push(...d)}else if(u.type==="marker"){let d=u.text;if(["**","*","__","_","~","+"].includes(d)){let f=d==="**"||d==="__"?"bold":d==="*"||d==="_"?"italic":d==="~"?"strike":"underline",m=l.findLastIndex(p=>p.text===d);m!==-1?l.splice(m,1):l.push({type:f,text:d,start:u.start})}}t.push(...c)}a(m2,"processMarkdownFormatting");function wu(e,t,r){if(!e)return;let o=/\{\{([^}]+)\}\}/g,n,i=0;for(o.lastIndex=0;(n=o.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;if(n.index>i){let c=e.substring(i,n.index);c&&r.push({type:"text",text:c,...t.length>0&&{marks:t}})}let s=n[1].trim(),l=t.some(c=>c.type==="link");s&&cr(s)?r.push({type:"variable",attrs:{id:s,...l&&{inUrlContext:!0}},...t.length>0&&{marks:t}}):r.push({type:"text",text:n[0],...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);s&&r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(wu,"parseTextWithVariables");function Qe(e,t){var d,f,m,p,y,h,v,C,P;let r={type:"doc",content:[]};if(!e||!e.elements||e.elements.length===0)return r;let o,n=t==null?void 0:t.channel,i;for(let b of e.elements)if(b.type==="channel"){let g=b;if(n){if(g.channel===n){i=g;break}}else{i=g;break}}if(!i||i.type!=="channel")return r;let s=i;if(s.elements&&s.elements.length>0?(o=s.elements,s.channel==="push"&&(o=o.map(b=>b.type==="meta"&&"title"in b?{type:"text",content:b.title||`
170
+ `,text_style:"h2"}:b))):o=[{type:"text",content:`
171
+ `}],!o||o.length===0)return r;let l=a(b=>{var g,N,T,R,E,w,k;if(b.type==="meta")return[];switch(b.type){case"text":if("content"in b){let x=b.text_style==="h1"?1:b.text_style==="h2"?2:null,A={};if(b.padding){let[L,I]=b.padding.replace(/px/g,"").split(" "),B=parseInt(L),F=parseInt(I);!isNaN(B)&&!isNaN(F)&&(A={paddingVertical:B,paddingHorizontal:F})}let M={};if(b.border_size||(g=b.border)!=null&&g.enabled||(N=b.border)!=null&&N.size){let L=b.border_size||((T=b.border)==null?void 0:T.size),I=b.border_color||((R=b.border)==null?void 0:R.color);M={...L&&{borderWidth:parseInt(L)},...I&&{borderColor:I}}}let S=b.content.trim()?Ep(b.content):[];return[{type:x?"heading":"paragraph",attrs:{textAlign:b.align||"left",level:x,id:`node-${(0,Or.v4)()}`,...A,...M,...b.background_color&&{backgroundColor:b.background_color},...b.locales&&{locales:b.locales}},content:S}]}return[];case"action":{let A=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"#000000",borderWidth:1,borderRadius:4}:{},M=b.content||"Button",S=[];return wu(M,[],S),S.length===0&&S.push({type:"text",text:M||"Button"}),[{type:"button",content:S,attrs:{label:M,link:b.href,alignment:b.align==="full"?"center":b.align||"center",size:b.align==="full"?"full":"default",style:b.style,id:`node-${(0,Or.v4)()}`,...A,...b.background_color&&{backgroundColor:b.background_color},...b.color&&{textColor:b.color},...b.padding&&{padding:parseInt(b.padding)},...((E=b.border)==null?void 0:E.enabled)&&{...b.border.color&&{borderColor:b.border.color},...b.border.size&&{borderWidth:parseInt(b.border.size)},...b.border.radius&&{borderRadius:b.border.radius}},...b.locales&&{locales:b.locales}}}]}case"quote":{let x="paragraph",A;b.text_style==="h1"?(x="heading",A=1):b.text_style==="h2"?(x="heading",A=2):b.text_style==="subtext"&&(x="heading",A=3);let M={textAlign:b.align||"left",id:`node-${(0,Or.v4)()}`};return A!==void 0&&(M.level=A),[{type:"blockquote",attrs:{textAlign:b.align||"left",id:`node-${(0,Or.v4)()}`,...b.border_color&&{borderColor:b.border_color},...b.border_left_width!==void 0&&{borderLeftWidth:b.border_left_width},...b.padding_horizontal!==void 0&&{paddingHorizontal:b.padding_horizontal},...b.padding_vertical!==void 0&&{paddingVertical:b.padding_vertical},...b.background_color&&{backgroundColor:b.background_color},...b.locales&&{locales:b.locales}},content:[{type:x,attrs:M,content:Ep(b.content)}]}]}case"image":{let x={};if(b.width){let S=b.width.endsWith("px"),L=parseInt(b.width.replace(/%|px/,""));if(S&&b.image_natural_width&&b.image_natural_width>0){let I=Math.round(L/b.image_natural_width*100);x.width=Math.max(1,Math.min(100,I)),x.imageNaturalWidth=b.image_natural_width}else x.width=L,b.image_natural_width&&(x.imageNaturalWidth=b.image_natural_width)}let A=b.border_size||((w=b.border)==null?void 0:w.size),M=b.border_color||((k=b.border)==null?void 0:k.color);return[{type:"imageBlock",attrs:{sourcePath:_s(b.src)?"":b.src,id:`node-${(0,Or.v4)()}`,...b.href&&{link:b.href},...b.align&&{alignment:b.align},...b.alt_text&&{alt:b.alt_text},...x,...A&&{borderWidth:parseInt(A),...M&&{borderColor:M}},...b.locales&&{locales:b.locales}}}]}case"divider":{let x=b.border_width||b.width;return[{type:"divider",attrs:{id:`node-${(0,Or.v4)()}`,...b.color&&{color:b.color},...x&&{size:parseInt(x)},...b.padding&&{padding:parseInt(b.padding)},variant:b.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${(0,Or.v4)()}`,code:b.content||"<!-- Add your HTML code here -->",...b.locales&&{locales:b.locales}}}];case"group":{let x=b.elements?b.elements.length:2,A=0,M=0;if(b.padding){let W=b.padding.split(" ");A=parseInt(W[0],10)||0,M=parseInt(W[1]||W[0],10)||0}let S=0,L=0,I="#000000";b.border&&(b.border.size&&(S=parseInt(b.border.size,10)||0),b.border.radius!==void 0&&(L=b.border.radius),b.border.color&&(I=b.border.color));let B=b.background_color||"transparent",F=`node-${(0,Or.v4)()}`,U=b.elements?b.elements.map((W,O)=>{var ee;if(W.type==="text"&&"content"in W&&((ee=W.content)==null?void 0:ee.trim())==="Drag and drop content blocks"&&W.align==="left")return{type:"columnCell",attrs:{index:O,columnId:F,isEditorMode:!1},content:[]};let Z;W.type==="group"&&W.elements?Z=W.elements.flatMap(l):Z=l(W);let te=Z.length>0?Z:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Or.v4)()}`},content:[]}];return{type:"columnCell",attrs:{index:O,columnId:F,isEditorMode:Z.length>0},content:te}}):[{type:"columnCell",attrs:{index:0,columnId:F,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Or.v4)()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:F,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Or.v4)()}`},content:[]}]}];return[{type:"column",attrs:{id:F,columnsCount:Math.min(Math.max(x,1),4),paddingVertical:A,paddingHorizontal:M,backgroundColor:B,borderWidth:S,borderRadius:L,borderColor:I,...b.locales&&{locales:b.locales}},content:[{type:"columnRow",content:U}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let b=0;b<u.length;b++){let g=u[b],N=u[b+1];if(g.type==="button"&&(N==null?void 0:N.type)==="button"&&n==="inbox"){let T={type:"buttonRow",attrs:{id:`node-${(0,Or.v4)()}`,button1Label:((d=g.attrs)==null?void 0:d.label)||"Button 1",button1Link:((f=g.attrs)==null?void 0:f.link)||"",button1BackgroundColor:((m=g.attrs)==null?void 0:m.backgroundColor)||"#000000",button1TextColor:((p=g.attrs)==null?void 0:p.textColor)||"#ffffff",button2Label:((y=N.attrs)==null?void 0:y.label)||"Button 2",button2Link:((h=N.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((v=N.attrs)==null?void 0:v.backgroundColor)||"#ffffff",button2TextColor:((C=N.attrs)==null?void 0:C.textColor)||"#000000",padding:((P=g.attrs)==null?void 0:P.padding)||6}};c.push(T),b++}else c.push(g)}return{type:"doc",content:c}}a(Qe,"convertElementalToTiptap");function kp(e,t){t.length!==0&&e.forEach(r=>{r.marks=r.marks||[],t.forEach(o=>{var n,i;(n=r.marks)!=null&&n.some(s=>s.type===o.type)||(i=r.marks)==null||i.push({type:o.type,...o.href&&{attrs:{href:o.href}}})}),r.marks.length===0&&delete r.marks})}a(kp,"applyMarks");function Mp(e,t,r){if(!e)return;let o=/{{([^}]+)}}/g,n,i=0;for(;(n=o.exec(e))!==null;){if(n.index>i){let l=e.substring(i,n.index);r.push({type:"text",text:l,...t.length>0&&{marks:t}})}let s=n[1].trim();cr(s)?r.push({type:"variable",attrs:{id:s},...t.length>0&&{marks:t}}):r.push({type:"text",text:n[0],...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(Mp,"parseTextWithVariables");function Eu(e){if(!e)return[];let t=[],r=/\[([^\]]+)\]\(([^)]+)\)/g,o,n=0;for(;(o=r.exec(e))!==null;)o.index>n&&t.push({type:"text",text:e.substring(n,o.index),start:n,end:o.index}),t.push({type:"link",text:o[1],start:o.index,end:o.index+o[1].length,attrs:{href:o[2]}}),n=o.index+o[0].length;n<e.length&&t.push({type:"text",text:e.substring(n),start:n,end:e.length});let i=[];for(let c of t){if(c.type==="link"){i.push(c);continue}let u=0,d=/(\*\*|\*|__|_|~|\+|{{[^}]+}})/g,f=c.text,m;for(;(m=d.exec(f))!==null;){let p=m.index,y=m[0],h=p+y.length;if(p>u&&i.push({type:"text",text:f.substring(u,p),start:c.start+u,end:c.start+p}),y.startsWith("{{")){let v=y.slice(2,-2).trim();cr(v)?i.push({type:"variable",text:y,start:c.start+p,end:c.start+h,attrs:{id:v}}):i.push({type:"text",text:y,start:c.start+p,end:c.start+h})}else i.push({type:"marker",text:y,start:c.start+p,end:c.start+h});u=h}u<f.length&&i.push({type:"text",text:f.substring(u),start:c.start+u,end:c.start+f.length})}i.sort((c,u)=>c.start-u.start);let s=[],l=[];for(let c of i)if(c.type==="text"){let u=[];Mp(c.text,[],u),kp(u,s),l.push(...u)}else if(c.type==="variable"){let u={type:"variable",attrs:c.attrs};kp([u],s),l.push(u)}else if(c.type==="link"){let u=[];Mp(c.text,[],u),u.forEach(d=>{var f;d.marks=d.marks||[],d.marks.push({type:"link",attrs:{href:(f=c.attrs)==null?void 0:f.href}})}),l.push(...u)}else if(c.type==="marker"){let u=c.text;if(["**","*","__","_","~","+"].includes(u)){let d=u==="**"||u==="__"?"bold":u==="*"||u==="_"?"italic":u==="~"?"strike":"underline",f=s.findLastIndex(m=>m.text===u);f!==-1?s.splice(f,1):s.push({type:d,text:u,start:c.start})}}return l}a(Eu,"processMarkdownFormatting");function p2(e){let t=[],r=e.split(/\n/);for(let o of r){if(!o.trim())continue;let n=o.match(/^(#{1,6})\s+(.*)$/);if(n){t.push({type:"heading",attrs:{level:n[1].length,textAlign:"left"},content:Eu(n[2])});continue}if(o.startsWith(">")){let s=o.slice(1).trim();t.push({type:"blockquote",attrs:{textAlign:"left"},content:[{type:"paragraph",attrs:{textAlign:"left"},content:Eu(s)}]});continue}if(o.match(/^-{3,}$/)){t.push({type:"divider"});continue}let i=o.match(/^!\[(.*?)\]\((.*?)(?:\s+"(.*?)")?\)$/);if(i){t.push({type:"imageBlock",attrs:{sourcePath:i[2],alt:i[1]||"",...i[3]&&{title:i[3]}}});continue}t.push({type:"paragraph",attrs:{textAlign:"left"},content:Eu(o)})}return t}a(p2,"parseBlockContent");function Pu(e){return{type:"doc",content:p2(e)}}a(Pu,"convertMarkdownToTiptap");var f2=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),js=a(e=>{var o,n,i,s;if(e.type==="variable")return`{{${(o=e.attrs)==null?void 0:o.id}}}`;let t=e.text||"";if((n=e.marks)!=null&&n.length){let l=e.marks.map(f2).filter(Boolean);t=l.join("")+t+l.reverse().join("")}let r=(i=e.marks)==null?void 0:i.find(l=>l.type==="link");return r&&(t=`[${t}](${(s=r.attrs)==null?void 0:s.href})`),t},"convertTextToMarkdown");function Ce(e){let t=a(r=>{var o,n,i,s,l,c,u,d,f,m,p,y,h,v,C,P,b,g,N,T,R,E,w,k,x,A,M,S,L,I,B,F,U,W,O,$,Z,te,ee,V,q,ce,fe,me,Me,mt,de,Ie,Pe,nt,it,Yt,Xt,at,pt,br,Qt,ie,yr,Kr,Yr,Ho,Un,zn,_n,$n,jn,H,J,ne,Ee,he,st,Nt,Xo,Ea;switch(r.type){case"paragraph":{let re="",ue=r.content||[];for(let Xe=0;Xe<ue.length;Xe++)ue[Xe].type==="hardBreak"?re+=`
172
+ `:re+=js(ue[Xe]);re+=`
173
+ `;let pe={};(o=r.attrs)!=null&&o.borderWidth&&(pe.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(pe.border_color=r.attrs.borderColor),((i=r.attrs)==null?void 0:i.paddingVertical)!==void 0&&((s=r.attrs)==null?void 0:s.paddingHorizontal)!==void 0&&(pe.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(pe.background_color=r.attrs.backgroundColor),pe.type="text",pe.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",pe.content=re;let Fe=pe;return(u=r.attrs)!=null&&u.locales&&(Fe.locales=r.attrs.locales),[Fe]}case"heading":{let re="",ue=r.content||[];for(let Xe=0;Xe<ue.length;Xe++)ue[Xe].type==="hardBreak"?re+=`
174
+ `:re+=js(ue[Xe]);re+=`
175
+ `;let pe={};(d=r.attrs)!=null&&d.borderWidth&&(pe.border_size=`${r.attrs.borderWidth}px`),(f=r.attrs)!=null&&f.borderColor&&(pe.border_color=r.attrs.borderColor),pe.text_style=((m=r.attrs)==null?void 0:m.level)===1?"h1":"h2",((p=r.attrs)==null?void 0:p.paddingVertical)!==void 0&&((y=r.attrs)==null?void 0:y.paddingHorizontal)!==void 0&&(pe.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(h=r.attrs)!=null&&h.backgroundColor&&(pe.background_color=r.attrs.backgroundColor),pe.type="text",pe.align=((v=r.attrs)==null?void 0:v.textAlign)||"left",pe.content=re;let Fe=pe;return(C=r.attrs)!=null&&C.locales&&(Fe.locales=r.attrs.locales),[Fe]}case"blockquote":{let re="",ue;if(r.content)for(let Fe of r.content){if(!ue&&Fe.type==="heading"){let Xe=(P=Fe.attrs)==null?void 0:P.level;Xe===1?ue="h1":Xe===2?ue="h2":ue="subtext"}if(Fe.content)for(let Xe of Fe.content)Xe.type==="hardBreak"?re+=`
176
+ `:re+=js(Xe);re+=`
177
+ `}re=re.trim();let pe={type:"quote",content:re};return((b=r.attrs)==null?void 0:b.textAlign)!=="left"&&(pe.align=(g=r.attrs)==null?void 0:g.textAlign),(N=r.attrs)!=null&&N.borderColor&&(pe.border_color=r.attrs.borderColor),((T=r.attrs)==null?void 0:T.borderLeftWidth)!==void 0&&(pe.border_left_width=r.attrs.borderLeftWidth),((R=r.attrs)==null?void 0:R.paddingHorizontal)!==void 0&&(pe.padding_horizontal=r.attrs.paddingHorizontal),((E=r.attrs)==null?void 0:E.paddingVertical)!==void 0&&(pe.padding_vertical=r.attrs.paddingVertical),(w=r.attrs)!=null&&w.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(pe.background_color=r.attrs.backgroundColor),ue&&(pe.text_style=ue),(k=r.attrs)!=null&&k.locales&&(pe.locales=r.attrs.locales),[pe]}case"imageBlock":{let re={},ue=(x=r.attrs)==null?void 0:x.width,pe=(A=r.attrs)==null?void 0:A.imageNaturalWidth;if(ue&&pe&&pe>0){let Xe=Math.round(ue/100*pe);re.width=`${Xe}px`,re.image_natural_width=pe}else ue&&(re.width=`${ue}%`);(M=r.attrs)!=null&&M.borderWidth&&(re.border_size=`${r.attrs.borderWidth}px`),(S=r.attrs)!=null&&S.borderColor&&(re.border_color=r.attrs.borderColor),re.type="image",re.src=((L=r.attrs)==null?void 0:L.sourcePath)||"",(I=r.attrs)!=null&&I.alignment&&(re.align=r.attrs.alignment),(B=r.attrs)!=null&&B.link&&(re.href=r.attrs.link),(F=r.attrs)!=null&&F.alt&&(re.alt_text=r.attrs.alt);let Fe=re;return(U=r.attrs)!=null&&U.locales&&(Fe.locales=r.attrs.locales),[Fe]}case"divider":{let re={type:"divider"};return(W=r.attrs)!=null&&W.color&&(re.color=r.attrs.color),(O=r.attrs)!=null&&O.size&&(re.border_width=`${r.attrs.size}px`),($=r.attrs)!=null&&$.padding&&(re.padding=`${r.attrs.padding}px 0px`),[re]}case"button":{let re=(te=(Z=r.attrs)==null?void 0:Z.label)!=null?te:"";r.content&&r.content.length>0&&(re=r.content.map(js).join(""));let ue={type:"action",content:re,href:(V=(ee=r.attrs)==null?void 0:ee.link)!=null?V:"#"};return(q=r.attrs)!=null&&q.style&&(ue.style=r.attrs.style),ue.align=((ce=r.attrs)==null?void 0:ce.size)==="full"?"full":((fe=r.attrs)==null?void 0:fe.alignment)||"center",(me=r.attrs)!=null&&me.backgroundColor&&(ue.background_color=r.attrs.backgroundColor),(Me=r.attrs)!=null&&Me.textColor&&(ue.color=r.attrs.textColor),(mt=r.attrs)!=null&&mt.padding&&(ue.padding=`${r.attrs.padding}px`),((de=r.attrs)!=null&&de.borderWidth||(Ie=r.attrs)!=null&&Ie.borderColor||(Pe=r.attrs)!=null&&Pe.borderRadius)&&(ue.border={enabled:!0},(nt=r.attrs)!=null&&nt.borderColor&&(ue.border.color=r.attrs.borderColor),(it=r.attrs)!=null&&it.borderWidth&&(ue.border.size=`${r.attrs.borderWidth}px`),(Yt=r.attrs)!=null&&Yt.borderRadius&&(ue.border.radius=r.attrs.borderRadius)),(Xt=r.attrs)!=null&&Xt.locales&&(ue.locales=r.attrs.locales),[ue]}case"buttonRow":{let re={type:"action",content:(pt=(at=r.attrs)==null?void 0:at.button1Label)!=null?pt:"Button 1",href:(Qt=(br=r.attrs)==null?void 0:br.button1Link)!=null?Qt:"#",align:"left"};(ie=r.attrs)!=null&&ie.button1BackgroundColor&&(re.background_color=r.attrs.button1BackgroundColor),(yr=r.attrs)!=null&&yr.button1TextColor&&(re.color=r.attrs.button1TextColor);let ue={type:"action",content:(Yr=(Kr=r.attrs)==null?void 0:Kr.button2Label)!=null?Yr:"Button 2",href:(Un=(Ho=r.attrs)==null?void 0:Ho.button2Link)!=null?Un:"#",align:"left"};return(zn=r.attrs)!=null&&zn.button2BackgroundColor&&(ue.background_color=r.attrs.button2BackgroundColor),(_n=r.attrs)!=null&&_n.button2TextColor&&(ue.color=r.attrs.button2TextColor),[re,ue]}case"customCode":{let re={type:"html",content:(($n=r.attrs)==null?void 0:$n.code)||"<!-- Add your HTML code here -->"};return(jn=r.attrs)!=null&&jn.locales&&(re.locales=r.attrs.locales),[re]}case"column":{let re=((H=r.attrs)==null?void 0:H.columnsCount)||2,ue=[],pe=(J=r.content)==null?void 0:J.find(ft=>ft.type==="columnRow");if(pe&&pe.content){for(let ft of pe.content)if(ft.type==="columnCell")if(ft.content&&ft.content.length>0){let Fs=ft.content.flatMap(t);Fs.length===0?ue.push({type:"text",content:`Drag and drop content blocks
178
+ `,align:"left"}):Fs.length===1?ue.push(Fs[0]):ue.push({type:"group",elements:Fs})}else ue.push({type:"text",content:`Drag and drop content blocks
179
+ `,align:"left"})}else for(let ft=0;ft<re;ft++)ue.push({type:"text",content:`Drag and drop content blocks
180
+ `,align:"left"});let Fe={type:"group"};if((ne=r.attrs)!=null&&ne.borderWidth&&r.attrs.borderWidth>0){let ft={};(Ee=r.attrs)!=null&&Ee.borderColor&&(ft.color=r.attrs.borderColor),ft.enabled=!0,ft.size=`${r.attrs.borderWidth}px`,(he=r.attrs)!=null&&he.borderRadius&&(ft.radius=r.attrs.borderRadius),Fe.border=ft}let Xe=((st=r.attrs)==null?void 0:st.paddingVertical)||0,ki=((Nt=r.attrs)==null?void 0:Nt.paddingHorizontal)||0;return(Xe>0||ki>0)&&(Fe.padding=`${Xe}px ${ki}px`),(Xo=r.attrs)!=null&&Xo.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(Fe.background_color=r.attrs.backgroundColor),Fe.elements=ue,(Ea=r.attrs)!=null&&Ea.locales&&(Fe.locales=r.attrs.locales),[Fe]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}a(Ce,"convertTiptapToElemental");function ku(e){let t="",r="";for(let o of e)if(!("visible"in o&&o.visible===!1)){if(o.type==="meta"&&"title"in o&&o.title)return o.title;if(o.type==="channel"&&"raw"in o&&o.raw){if("subject"in o.raw&&o.raw.subject)return o.raw.subject;if("title"in o.raw&&o.raw.title)return o.raw.title}if(o.type==="text"&&"content"in o&&o.content){let n=o.content.trim();n&&n!==`
181
+ `&&("text_style"in o&&(o.text_style==="h1"||o.text_style==="h2")?r||(r=n):t||(t=n))}if(o.type==="channel"&&"elements"in o&&o.elements){let n=ku(o.elements);if(n)return n}}return r||t||""}a(ku,"getTitle");function Mu(e,t){if(!e||!e.elements)return"";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"";if("raw"in r&&r.raw){if("subject"in r.raw&&r.raw.subject)return r.raw.subject;if("title"in r.raw&&r.raw.title)return r.raw.title}if("elements"in r&&r.elements){if(t==="email"){let o=r.elements.find(n=>n.type==="meta");return o&&"title"in o&&o.title?o.title:""}return ku(r.elements)}return""}a(Mu,"getTitleForChannel");function St(e,t){var s;let r=e||{version:"2022-01-01",elements:[]},o={...r,elements:[]},n;typeof t.channel=="string"?n=t.channel:t.channel&&typeof t.channel.channel=="string"?n=t.channel.channel:t.channel;let i=!1;if(r.elements&&Array.isArray(r.elements)&&r.elements.forEach(l=>{var c;if(l.type!=="meta")if(l.type==="channel"){let u=l,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let f={};if(t.channel&&typeof t.channel=="object")for(let p in t.channel)p!=="type"&&p!=="elements"&&p!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,p)&&(f[p]=t.channel[p]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([p])=>!["type","channel","elements"].includes(p))),...f};if(t.elements!==void 0){let p=[],y=t.elements.find(v=>v.type==="meta");if(y)p.push(y);else{let v=(c=u.elements)==null?void 0:c.find(C=>C.type==="meta");v&&p.push(v)}let h=t.elements.filter(v=>v.type!=="meta");p.push(...h),m.elements=p}o.elements.push(m),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((s=r.elements)!=null&&s.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};if(t.channel&&typeof t.channel=="object")for(let d in t.channel)d!=="type"&&d!=="elements"&&d!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,d)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],f=t.elements.find(p=>p.type==="meta");f&&d.push(f);let m=t.elements.filter(p=>p.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}a(St,"updateElemental");function D(...e){return(0,Np.twMerge)((0,Ap.clsx)(e))}a(D,"cn");var Sp=require("@radix-ui/react-slot"),Ip=require("class-variance-authority"),Lp=require("react"),Rp=require("react/jsx-runtime"),Zs=(0,Ip.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6] dark:courier-text-foreground dark:courier-bg-white dark:courier-border-white",secondary:"courier-text-foreground courier-bg-[#F5F5F5]",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-800 active:courier-bg-neutral-900 dark:hover:courier-bg-neutral-200 dark:active:courier-bg-neutral-300"},{variant:"primary",active:!0,class:"courier-bg-neutral-900 dark:courier-bg-neutral-300"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-900 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-white/20 dark:courier-text-neutral-200"}]}),Ve=(0,Lp.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...s},l)=>(0,Rp.jsx)(i?Sp.Slot:"button",{ref:l,disabled:r,className:D(Zs({variant:o,size:t,disabled:r,active:e}),n),...s}));Ve.displayName="Button";var Dp=require("react"),Bp=require("react/jsx-runtime"),be=(0,Dp.forwardRef)((e,t)=>(0,Bp.jsx)("hr",{...e,ref:t,className:D("courier-my-1 courier-border-border dark:courier-border-neutral-800 courier-w-full",e.className)}));be.displayName="Divider";var Qo=Ae(require("react"),1),xe=Ae(require("@radix-ui/react-dropdown-menu"),1),Hi=require("lucide-react");var wt=require("react/jsx-runtime"),qs=xe.Root,Js=xe.Trigger;var g2=Qo.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,wt.jsxs)(xe.SubTrigger,{ref:n,className:D("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,wt.jsx)(Hi.ChevronRight,{className:"courier-ml-auto"})]}));g2.displayName=xe.SubTrigger.displayName;var h2=Qo.forwardRef(({className:e,...t},r)=>(0,wt.jsx)(xe.SubContent,{ref:r,className:D("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));h2.displayName=xe.SubContent.displayName;var Aa=Qo.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,wt.jsx)(xe.Portal,{...r,children:(0,wt.jsx)(xe.Content,{ref:n,sideOffset:t,className:D("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));Aa.displayName=xe.Content.displayName;var Na=Qo.forwardRef(({className:e,inset:t,...r},o)=>(0,wt.jsx)(xe.Item,{ref:o,className:D("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));Na.displayName=xe.Item.displayName;var b2=Qo.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,wt.jsxs)(xe.CheckboxItem,{ref:n,className:D("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,wt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,wt.jsx)(xe.ItemIndicator,{children:(0,wt.jsx)(Hi.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));b2.displayName=xe.CheckboxItem.displayName;var y2=Qo.forwardRef(({className:e,children:t,...r},o)=>(0,wt.jsxs)(xe.RadioItem,{ref:o,className:D("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,wt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,wt.jsx)(xe.ItemIndicator,{children:(0,wt.jsx)(Hi.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));y2.displayName=xe.RadioItem.displayName;var v2=Qo.forwardRef(({className:e,inset:t,...r},o)=>(0,wt.jsx)(xe.Label,{ref:o,className:D("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));v2.displayName=xe.Label.displayName;var C2=Qo.forwardRef(({className:e,...t},r)=>(0,wt.jsx)(xe.Separator,{ref:r,className:D("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));C2.displayName=xe.Separator.displayName;var x2=a(({className:e,...t})=>(0,wt.jsx)("span",{className:D("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");x2.displayName="DropdownMenuShortcut";var Hp=require("react");var Fi=require("react/jsx-runtime"),Au=class Au extends Hp.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,Fi.jsx)(T2,{error:this.state.error}):this.props.children}};a(Au,"ErrorBoundary");var Gs=Au,T2=a(({error:e})=>(0,Fi.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,Fi.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,Fi.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var Wp=require("@radix-ui/react-slot"),Cr=Ae(require("react"),1),Vi=require("react-hook-form");var Nu=Ae(require("@radix-ui/react-label"),1),Fp=require("class-variance-authority"),Vp=Ae(require("react"),1),Op=require("react/jsx-runtime"),w2=(0,Fp.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),Su=Vp.forwardRef(({className:e,...t},r)=>(0,Op.jsx)(Nu.Root,{ref:r,className:D(w2(),e),...t}));Su.displayName=Nu.Root.displayName;var en=require("react/jsx-runtime"),et=Vi.FormProvider,Up=Cr.createContext({}),X=a(({...e})=>(0,en.jsx)(Up.Provider,{value:{name:e.name},children:(0,en.jsx)(Vi.Controller,{...e})}),"FormField"),Ks=a(()=>{let e=Cr.useContext(Up),t=Cr.useContext(zp),{getFieldState:r,formState:o}=(0,Vi.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),zp=Cr.createContext({}),K=Cr.forwardRef(({className:e,...t},r)=>{let o=Cr.useId();return(0,en.jsx)(zp.Provider,{value:{id:o},children:(0,en.jsx)("div",{ref:r,className:D("courier-space-y-2",e),...t})})});K.displayName="FormItem";var Oo=Cr.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=Ks();return(0,en.jsx)(Su,{ref:r,className:D(o&&"courier-text-destructive",e),htmlFor:n,...t})});Oo.displayName="FormLabel";var Y=Cr.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=Ks();return(0,en.jsx)(Wp.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});Y.displayName="FormControl";var E2=Cr.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=Ks();return(0,en.jsx)("p",{ref:r,id:o,className:D("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});E2.displayName="FormDescription";var Q=Cr.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=Ks(),s=n?String(n==null?void 0:n.message):t;return s?(0,en.jsx)("p",{ref:o,id:i,className:D("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:s}):null});Q.displayName="FormMessage";var Ze=Ae(require("@radix-ui/react-alert-dialog"),1),Gn=Ae(require("react"),1);var _p=require("react");var Wr=require("react/jsx-runtime"),$p=Ze.Root,jp=Ze.Trigger,P2=Ze.Portal,Zp=Gn.forwardRef(({className:e,...t},r)=>(0,Wr.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,Wr.jsx)(Ze.Overlay,{asChild:!0,className:D("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));Zp.displayName=Ze.Overlay.displayName;var Iu=Gn.forwardRef(({className:e,...t},r)=>{let o=(0,_p.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,Wr.jsxs)(P2,{container:typeof window!="undefined"?o():void 0,children:[(0,Wr.jsx)(Zp,{}),(0,Wr.jsx)(Ze.Content,{ref:r,className:D("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});Iu.displayName=Ze.Content.displayName;var Lu=a(({className:e,...t})=>(0,Wr.jsx)("div",{className:D("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");Lu.displayName="AlertDialogHeader";var Ru=a(({className:e,...t})=>(0,Wr.jsx)("div",{className:D("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Ru.displayName="AlertDialogFooter";var k2=Gn.forwardRef(({className:e,...t},r)=>(0,Wr.jsx)(Ze.Title,{ref:r,className:D("courier-text-lg courier-font-semibold",e),...t}));k2.displayName=Ze.Title.displayName;var M2=Gn.forwardRef(({className:e,...t},r)=>(0,Wr.jsx)(Ze.Description,{ref:r,className:D("courier-text-sm courier-text-muted-foreground",e),...t}));M2.displayName=Ze.Description.displayName;var Du=Gn.forwardRef(({className:e,...t},r)=>(0,Wr.jsx)(Ze.Action,{ref:r,className:D(Zs(),e),...t}));Du.displayName=Ze.Action.displayName;var Bu=Gn.forwardRef(({className:e,...t},r)=>(0,Wr.jsx)(Ze.Cancel,{ref:r,className:D(Zs({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));Bu.displayName=Ze.Cancel.displayName;var qp=Ae(require("react"),1),Oi=require("react/jsx-runtime"),ye=qp.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,Oi.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,Oi.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,Oi.jsx)("input",{type:t,className:D("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,Oi.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));ye.displayName="Input";var yn=require("react");var ur=require("react");var Jp=require("lucide-react");var xr=require("react/jsx-runtime"),A2=a(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),Gp=a(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,s]=(0,ur.useState)(()=>Sa(e)),[l,c]=(0,ur.useState)(e),u=(0,ur.useRef)(null),d=(0,ur.useRef)(null),f=(0,ur.useRef)(null),m=(0,ur.useRef)(!1),p=e!==n,y=(0,ur.useCallback)(b=>{m.current=!0;let g=N2(b);c(g),t(g),m.current=!1},[t]),h=a(b=>g=>{f.current=b,v(g)},"handleMouseDown"),v=(0,ur.useCallback)(b=>{if(f.current){if(f.current==="gradient"&&u.current){let g=u.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(b.clientX-g.left)/g.width)),T=Math.max(0,Math.min(1,(b.clientY-g.top)/g.height)),R={...i,s:N*100,v:(1-T)*100};s(R),y(R)}else if(f.current==="hue"&&d.current){let g=d.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(b.clientX-g.left)/g.width)),T={...i,h:N*360};s(T),y(T)}}},[i,y]),C=(0,ur.useCallback)(()=>{f.current=null},[]);(0,ur.useEffect)(()=>{if(f.current)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",C)}},[v,C]),(0,ur.useEffect)(()=>{m.current||(s(Sa(e)),c(e))},[e]);let P=a(b=>{let g=b.target.value;if(c(g),A2(g)){let N=Sa(g);s(N),y(N)}},"handleInputChange");return(0,xr.jsxs)("div",{className:D("w-full",r),children:[(0,xr.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,xr.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,xr.jsx)("div",{ref:d,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,xr.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,xr.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,xr.jsx)(ye,{value:l,onChange:P,placeholder:"#000000",className:"courier-flex-1"}),p&&(0,xr.jsx)("button",{onClick:b=>{if(b.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let g=Sa(n);s(g),y(g)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,xr.jsx)(Jp.CircleX,{size:14,strokeWidth:1.25})})]}),(0,xr.jsx)(be,{className:"courier-my-3"}),(0,xr.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(b=>(0,xr.jsx)("button",{className:D("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",b==="transparent"&&Hu),style:{backgroundColor:b==="transparent"?void 0:b},onClick:g=>{if(g.preventDefault(),b==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let N=Sa(b);s(N),y(N)}},b))})]})},"ColorPicker");function Sa(e){if(e==="transparent")return{h:0,s:0,v:0};let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,n=Math.max(t,r,o),i=Math.min(t,r,o),s=n-i,l=0,c=n===0?0:s/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/s+(r<o?6:0);break;case r:l=(o-t)/s+2;break;case o:l=(t-r)/s+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}a(Sa,"hexToHsv");function N2({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=a(l=>{let c=(l+e*6)%6;return r-r*t*Math.max(0,Math.min(c,4-c,1))},"f"),n=Math.round(o(5)*255),i=Math.round(o(3)*255),s=Math.round(o(1)*255);return`#${[n,i,s].map(l=>l.toString(16).padStart(2,"0")).join("")}`}a(N2,"hsvToHex");var Wo=Ae(require("@radix-ui/react-popover"),1),Kp=Ae(require("react"),1);var Fu=require("react/jsx-runtime"),Yp=Wo.Root,Xp=Wo.Trigger;var Vu=Kp.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:s,...l},c)=>(0,Fu.jsx)(Wo.Portal,{...s,children:(0,Fu.jsx)(Wo.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:D("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...l})}));Vu.displayName=Wo.Content.displayName;var tn=require("react/jsx-runtime"),Hu="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",S2=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Et=(0,yn.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=S2,...s},l)=>{let c=t!=="transparent",u=(0,yn.useRef)(null),d=(0,yn.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),f=(0,yn.useCallback)(()=>{var p;let m=(p=u.current)==null?void 0:p.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,tn.jsxs)(Yp,{children:[(0,tn.jsx)(Xp,{asChild:!0,children:(0,tn.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,tn.jsx)("div",{className:D("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",c?"":Hu),style:{backgroundColor:c?t:void 0}}),(0,tn.jsx)(ye,{...s,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:D("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,tn.jsx)(Vu,{portalProps:{container:typeof window!="undefined"?f():void 0},className:"courier-w-[230px]",children:(0,tn.jsx)(Gp,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});Et.displayName="InputColor";var Qp=Ae(require("react"),1),Ou=Ae(require("@radix-ui/react-separator"),1);var ef=require("react/jsx-runtime"),Wu=Qp.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,ef.jsx)(Ou.Root,{ref:n,decorative:r,orientation:t,className:D("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));Wu.displayName=Ou.Root.displayName;var tf=Ae(require("react"),1),rn=Ae(require("@radix-ui/react-slider"),1);var Wi=require("react/jsx-runtime"),Uu=tf.forwardRef(({className:e,...t},r)=>(0,Wi.jsxs)(rn.Root,{ref:r,className:D("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,Wi.jsx)(rn.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,Wi.jsx)(rn.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,Wi.jsx)(rn.Thumb,{className:"courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-accent-foreground courier-shadow courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50"})]}));Uu.displayName=rn.Root.displayName;var rf=Ae(require("react"),1),Ia=Ae(require("@radix-ui/react-switch"),1);var zu=require("react/jsx-runtime"),Ui=rf.forwardRef(({className:e,...t},r)=>(0,zu.jsx)(Ia.Root,{className:D("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,zu.jsx)(Ia.Thumb,{className:D("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));Ui.displayName=Ia.Root.displayName;var Ys=Ae(require("react"),1),go=Ae(require("@radix-ui/react-tabs"),1);var el=require("react/jsx-runtime"),Xs=go.Root,La=Ys.forwardRef(({className:e,...t},r)=>(0,el.jsx)(go.List,{ref:r,className:D("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));La.displayName=go.List.displayName;var zi=Ys.forwardRef(({className:e,...t},r)=>(0,el.jsx)(go.Trigger,{ref:r,className:D("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));zi.displayName=go.Trigger.displayName;var Qs=Ys.forwardRef(({className:e,...t},r)=>(0,el.jsx)(go.Content,{ref:r,className:D("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));Qs.displayName=go.Content.displayName;var _i=Ae(require("react"),1);var of=require("react/jsx-runtime"),_u=_i.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=_i.useRef(null),i=a(s=>{n.current=s,typeof o=="function"?o(s):o&&(o.current=s)},"combinedRef");return _i.useEffect(()=>{if(!t)return;let s=n.current;if(!s)return;let l=a(()=>{s.style.height="auto",s.style.height=`${s.scrollHeight}px`},"adjustHeight");return l(),s.addEventListener("input",l),()=>{s.removeEventListener("input",l)}},[t]),(0,of.jsx)("textarea",{className:D("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});_u.displayName="Textarea";var ju=require("react");var sf=require("react");var tl={colorScheme:"light",background:"#ffffff",foreground:"#404040",muted:"#D9D9D9",mutedForeground:"#A3A3A3",popover:"#ffffff",popoverForeground:"#292929",border:"#DCDEE4",input:"#DCDEE4",card:"#FAF9F8",cardForeground:"#292929",primary:"#ffffff",primaryForeground:"#696F8C",secondary:"#F5F5F5",secondaryForeground:"#171717",accent:"#E5F3FF",accentForeground:"#1D4ED8",destructive:"#292929",destructiveForeground:"#FF3363",ring:"#80849D",radius:"6px"},nf={...tl},af={...tl,colorScheme:"dark",foreground:"#d4d4d4",background:"#262626",card:"#262626",primary:"#262626"};var lf=(0,sf.createContext)(tl);var $u=require("react/jsx-runtime"),cf=(0,ju.forwardRef)(({children:e,theme:t,dataMode:r="light",className:o},n)=>{let i=r==="light"?nf:af,s=i;t&&(s=typeof t=="string"?t:{...i,...t});let l=typeof t=="string"?{}:Object.entries(s).reduce((c,[u,d])=>{let f=u.replace(/[A-Z]/g,m=>`-${m.toLowerCase()}`);return{...c,[`--${f}`]:d}},{});return(0,$u.jsx)(lf.Provider,{value:typeof s=="object"?s:{},children:(0,$u.jsx)("div",{style:l,className:D("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",o),ref:n,children:e})})});var uf=Ae(require("react"),1),Zu=Ae(require("@radix-ui/react-toggle"),1),df=require("class-variance-authority");var mf=require("react/jsx-runtime"),qu=(0,df.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),I2=uf.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,mf.jsx)(Zu.Root,{ref:n,className:D(qu({variant:t,size:r,className:e})),...o}));I2.displayName=Zu.Root.displayName;var $i=Ae(require("@radix-ui/react-toggle-group"),1),Kn=Ae(require("react"),1);var rl=require("react/jsx-runtime"),pf=Kn.createContext({size:"default",variant:"default"}),er=Kn.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,rl.jsx)($i.Root,{ref:i,className:D("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,rl.jsx)(pf.Provider,{value:{variant:t,size:r},children:o})}));er.displayName=$i.Root.displayName;var tt=Kn.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let s=Kn.useContext(pf);return(0,rl.jsx)($i.Item,{ref:i,className:D(qu({variant:s.variant||r,size:s.size||o}),e),...n,children:t})});tt.displayName=$i.Item.displayName;var ol=require("react/jsx-runtime"),We=a(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,ol.jsx)("path",{className:D(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,ol.jsx)("path",{className:D(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),G=a(({width:e=28,height:t=28,...r})=>(0,ol.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ji=require("react/jsx-runtime"),ff=a(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ji.jsxs)(G,{...o,width:t,height:r,children:[(0,ji.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,ji.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ji.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var Ju=require("react/jsx-runtime"),Ra=a(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,Ju.jsx)(G,{...o,fill:"none",width:t,height:r,children:(0,Ju.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var Gu=require("react/jsx-runtime"),Da=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Gu.jsx)(G,{...n,width:r,height:o,children:(0,Gu.jsx)(We,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var Zi=require("react/jsx-runtime"),ho=a(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,Zi.jsxs)(G,{...o,width:t,height:r,children:[(0,Zi.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,Zi.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,Zi.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var Ku=require("react/jsx-runtime"),Yu=a(({color:e,width:t=21,height:r=16,...o})=>(0,Ku.jsx)(G,{...o,width:t,height:r,children:(0,Ku.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var Xu=require("react/jsx-runtime"),Qu=a(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,Xu.jsx)(G,{...o,fill:"none",width:t,height:r,children:(0,Xu.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var ed=require("react/jsx-runtime"),td=a(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,ed.jsx)(G,{...n,width:t,height:r,viewBox:o,children:(0,ed.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var rd=require("react/jsx-runtime"),Ba=a(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,rd.jsx)(G,{...o,width:t,height:r,children:(0,rd.jsx)(We,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var od=require("react/jsx-runtime"),Ha=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,od.jsx)(G,{...n,width:r,height:o,children:(0,od.jsx)(We,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var nd=require("react/jsx-runtime"),id=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,nd.jsx)(G,{...o,width:t,height:r,children:(0,nd.jsx)(We,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var ad=require("react/jsx-runtime"),Fa=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,ad.jsx)(G,{...o,width:t,height:r,children:(0,ad.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var sd=require("react/jsx-runtime"),Va=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,sd.jsx)(G,{...n,width:r,height:o,children:(0,sd.jsx)(We,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var ld=require("react/jsx-runtime"),Oa=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,ld.jsx)(G,{...n,width:r,height:o,children:(0,ld.jsx)(We,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var cd=require("react/jsx-runtime"),ud=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,cd.jsx)(G,{...n,width:t,height:r,viewBox:o,children:(0,cd.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var dd=require("react/jsx-runtime"),Wa=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,dd.jsx)(G,{...n,width:r,height:o,children:(0,dd.jsx)(We,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var nl=require("react/jsx-runtime"),md=a(({color:e,width:t=21,height:r=16,...o})=>(0,nl.jsx)(G,{...o,width:t,height:r,children:(0,nl.jsx)("g",{transform:"translate(4, 0)",children:(0,nl.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var pd=require("react/jsx-runtime"),fd=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,pd.jsx)(G,{...o,width:t,height:r,children:(0,pd.jsx)(We,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var gd=require("react/jsx-runtime"),Ua=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,gd.jsx)(G,{...n,width:r,height:o,children:(0,gd.jsx)(We,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var hd=require("react/jsx-runtime"),Yn=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,hd.jsx)(G,{...n,width:r,height:o,children:(0,hd.jsx)(We,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var za=require("react/jsx-runtime"),bd=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 20 21",...n})=>(0,za.jsxs)(G,{...n,width:t,height:r,viewBox:o,children:[(0,za.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:e}),(0,za.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:e,stroke:"white","stroke-width":"2"})]}),"PushIcon");var yd=require("react/jsx-runtime"),vd=a(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,yd.jsx)(G,{...o,fill:"none",width:t,height:r,children:(0,yd.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var Cd=require("react/jsx-runtime"),xd=a(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,Cd.jsx)(G,{...o,width:t,height:r,children:(0,Cd.jsx)(We,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var Td=require("react/jsx-runtime"),wd=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Td.jsx)(G,{...o,width:t,height:r,children:(0,Td.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var vn=require("react/jsx-runtime"),gf=a(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,vn.jsx)(G,{...o,width:t,height:r,children:(0,vn.jsxs)("g",{opacity:"0.9",children:[(0,vn.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var Ed=require("react/jsx-runtime"),Pd=a(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Ed.jsx)(G,{...o,width:t,height:r,children:(0,Ed.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var kd=require("react/jsx-runtime"),_a=a(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,kd.jsx)(G,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,kd.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var Md=require("react/jsx-runtime"),$a=a(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,Md.jsx)(G,{...o,width:t,height:r,children:(0,Md.jsx)(We,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var Xn=require("react/jsx-runtime"),hf=a(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,Xn.jsx)(G,{...o,width:t,height:r,children:(0,Xn.jsxs)("g",{opacity:"0.9",children:[(0,Xn.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,Xn.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,Xn.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var Ad=require("react/jsx-runtime"),ja=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Ad.jsx)(G,{...n,width:r,height:o,children:(0,Ad.jsx)(We,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var bf=require("lucide-react"),ti=require("react");var il=require("react/jsx-runtime"),Qn=a(({className:e})=>(0,il.jsx)("div",{className:D("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,il.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,il.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var ei=require("react/jsx-runtime"),qi=a(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[s,l]=(0,ti.useState)(!1),c=(0,ti.useRef)(t),u=(0,ti.useRef)(null);return(0,ti.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,ei.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ei.jsx)(Qn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,ei.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):s?i?i(s):(0,ei.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ei.jsx)(bf.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var Nd=require("jotai");var ri=require("react/jsx-runtime"),Cn=[{label:"Email",value:"email",icon:(0,ri.jsx)(td,{})},{label:"SMS",value:"sms",icon:(0,ri.jsx)(wd,{})},{label:"Push",value:"push",icon:(0,ri.jsx)(bd,{})},{label:"In-app",value:"inbox",icon:(0,ri.jsx)(Fa,{})},{label:"Slack",value:"slack",icon:(0,ri.jsx)(Pd,{})},{label:"Teams",value:"msteams",icon:(0,ri.jsx)(ud,{})}];var xn=(0,Nd.atom)("email"),Ji=(0,Nd.atom)("template");var Hb=require("@radix-ui/react-alert-dialog"),gn=require("jotai"),Ko=require("react");var Tr=require("jotai");var Sd={contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},al=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"}};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"}};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var L2={paragraph:Sd,heading:Sd},Za=(0,Tr.atom)(L2),ke=(0,Tr.atom)(null),gt=(0,Tr.atom)(null,(e,t,r)=>{t(ke,r)}),R2=(0,Tr.atom)({ref:null,caretPosition:null}),sl=(0,Tr.atom)({ref:null,caretPosition:null}),qa=(0,Tr.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),yf=(0,Tr.atom)(e=>(t,r=!1)=>{let o=e(Za),n=e(qa),i=al(t,r),s=o[t],l=i;return s&&Object.keys(s).forEach(c=>{var d,f;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((f=s[u])==null?void 0:f.state)==="enabled"&&(l[u]=s[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),vf=(0,Tr.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(Za);t(Za,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,s])=>[i,{state:!Array.isArray(s)&&(s!=null&&s.state)?s.state:"hidden"}]))}})}),j4=(0,Tr.atom)(null,(e,t,r)=>{let o=e(Za),{[r]:n,...i}=o;t(Za,i)}),Cf=(0,Tr.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(R2,{ref:r,caretPosition:o})}),Z4=(0,Tr.atom)(null,(e,t,r)=>{let o=e(qa);t(qa,{...o,showVariablePopup:r})}),Id=(0,Tr.atom)(null),ll=(0,Tr.atom)(null,(e,t,r)=>{t(Id,r)});var fn=require("jotai"),Vr=require("react");var Ld=require("jotai"),bo=(0,Ld.atom)(null),Uo=(0,Ld.atom)(null);var xf=require("react"),Tf=require("sonner");var Tn=require("react/jsx-runtime"),wr=(0,xf.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,dataMode:n="light",className:i,...s},l)=>(0,Tn.jsx)(cf,{theme:e,ref:l,dataMode:n,className:i,children:(0,Tn.jsxs)("div",{...Object.fromEntries(Object.entries(s).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,Tn.jsx)("div",{className:"courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-primary",children:o}),r&&(0,Tn.jsx)("div",{className:"courier-editor-loading",children:(0,Tn.jsx)(Qn,{})}),(0,Tn.jsx)(Tf.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var Ar=require("jotai"),Le=require("react");function wf(e){if(Array.isArray(e))return e}a(wf,"_arrayWithHoles");function Ef(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,s,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(d){u=!0,n=d}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}a(Ef,"_iterableToArrayLimit");function Ja(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(Ja,"_arrayLikeToArray");function cl(e,t){if(e){if(typeof e=="string")return Ja(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ja(e,t):void 0}}a(cl,"_unsupportedIterableToArray");function Pf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
182
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(Pf,"_nonIterableRest");function ul(e,t){return wf(e)||Ef(e,t)||cl(e,t)||Pf()}a(ul,"_slicedToArray");var c1=Ae(Ga());var ml="data-pdnd-honey-pot";function pl(e){return e instanceof Element&&e.hasAttribute(ml)}a(pl,"isHoneyPotElement");function fl(e){var t=document.elementsFromPoint(e.x,e.y),r=ul(t,2),o=r[0],n=r[1];return o?pl(o)?n!=null?n:null:o:null}a(fl,"getElementFromPointWithoutHoneypot");function oi(e){"@babel/helpers - typeof";return oi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oi(e)}a(oi,"_typeof");function Af(e,t){if(oi(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(oi(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}a(Af,"toPrimitive");function Nf(e){var t=Af(e,"string");return oi(t)=="symbol"?t:t+""}a(Nf,"toPropertyKey");function on(e,t,r){return(t=Nf(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(on,"_defineProperty");var Ya=Ae(Ga());var Sf=2147483647;function If(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(If,"ownKeys");function Lf(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?If(Object(r),!0).forEach(function(o){on(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):If(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(Lf,"_objectSpread");var Ka=2,Rf=Ka/2;function W2(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}a(W2,"floorToClosestPixel");function U2(e){return{x:e.x-Rf,y:e.y-Rf}}a(U2,"pullBackByHalfHoneyPotSize");function z2(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}a(z2,"preventGoingBackwardsOffScreen");function _2(e){return{x:Math.min(e.x,window.innerWidth-Ka),y:Math.min(e.y,window.innerHeight-Ka)}}a(_2,"preventGoingForwardsOffScreen");function Df(e){var t=e.client,r=_2(z2(U2(W2(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:Ka,height:Ka})}a(Df,"getHoneyPotRectFor");function Bf(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}a(Bf,"getRectStyles");function $2(e){var t=e.client,r=e.clientRect;return t.x>=r.x&&t.x<=r.x+r.width&&t.y>=r.y&&t.y<=r.y+r.height}a($2,"isWithin");function j2(e){var t=e.initial,r=document.createElement("div");r.setAttribute(ml,"true");var o=Df({client:t});Object.assign(r.style,Lf(Lf({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},Bf({clientRect:o})),{},{pointerEvents:"auto",zIndex:Sf})),document.body.appendChild(r);var n=(0,Ya.bind)(window,{type:"pointermove",listener:a(function(s){var l={x:s.clientX,y:s.clientY};o=Df({client:l}),Object.assign(r.style,Bf({clientRect:o}))},"listener"),options:{capture:!0}});return a(function(s){var l=s.current;if(n(),$2({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}a(c,"cleanup");var u=(0,Ya.bindAll)(window,[{type:"pointerdown",listener:c},{type:"pointermove",listener:c},{type:"focusin",listener:c},{type:"focusout",listener:c},{type:"dragstart",listener:c},{type:"dragenter",listener:c},{type:"dragover",listener:c}],{capture:!0})},"finish")}a(j2,"mountHoneyPot");function Hf(){var e=null;function t(){return e=null,(0,Ya.bind)(window,{type:"pointermove",listener:a(function(n){e={x:n.clientX,y:n.clientY}},"listener"),options:{capture:!0}})}a(t,"bindEvents");function r(){var o=null;return a(function(i){var s=i.eventName,l=i.payload;if(s==="onDragStart"){var c=l.location.initial.input,u=e!=null?e:{x:c.clientX,y:c.clientY};o=j2({initial:u})}if(s==="onDrop"){var d,f=l.location.current.input;(d=o)===null||d===void 0||d({current:{x:f.clientX,y:f.clientY}}),o=null,e=null}},"onPostEvent")}return a(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}a(Hf,"makeHoneyPotFix");function Ff(e){if(Array.isArray(e))return Ja(e)}a(Ff,"_arrayWithoutHoles");function Vf(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}a(Vf,"_iterableToArray");function Of(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
183
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(Of,"_nonIterableSpread");function gl(e){return Ff(e)||Vf(e)||cl(e)||Of()}a(gl,"_toConsumableArray");var Jf=Ae(Ga());function eo(e){var t=null;return a(function(){if(!t){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];var s=e.apply(this,n);t={result:s}}return t.result},"wrapped")}a(eo,"once");var Wf=eo(a(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var Xa=eo(a(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Uf=Ae(Ga());var Dd={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function zf(e){var t=e.dragLeave;return Xa()?t.hasOwnProperty(Dd.isLeavingWindow):!1}a(zf,"isLeavingWindowInSafari");a(function(){if(typeof window=="undefined"||!Xa())return;function t(){return{enterCount:0,isOverWindow:!1}}a(t,"getInitialState");var r=t();function o(){r=t()}a(o,"resetState"),(0,Uf.bindAll)(window,[{type:"dragstart",listener:a(function(){r.enterCount=0,r.isOverWindow=!0},"listener")},{type:"drop",listener:o},{type:"dragend",listener:o},{type:"dragenter",listener:a(function(i){!r.isOverWindow&&r.enterCount===0&&(i[Dd.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:a(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[Dd.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function Z2(e){return"nodeName"in e}a(Z2,"isNodeLike");function _f(e){return Z2(e)&&e.ownerDocument!==document}a(_f,"isFromAnotherWindow");function $f(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:Xa()?zf({dragLeave:t}):o==null?!0:Wf()?_f(o):o instanceof HTMLIFrameElement}a($f,"isLeavingWindow");function jf(e){var t=e.onDragEnd;return[{type:"pointermove",listener:function(){var r=0;return a(function(){if(r<20){r++;return}t()},"listener")}()},{type:"pointerdown",listener:t}]}a(jf,"getBindingsForBrokenDrags");function ni(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}a(ni,"getInput");var q2=a(function(t){var r=[],o=null,n=a(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];r=l,!o&&(o=requestAnimationFrame(function(){o=null,t.apply(void 0,r)}))},"wrapperFn");return n.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},n},"rafSchd"),Zf=q2;var Bd=Zf(function(e){return e()}),hl=function(){var e=null;function t(o){var n=requestAnimationFrame(function(){e=null,o()});e={frameId:n,fn:o}}a(t,"schedule");function r(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return a(r,"flush"),{schedule:t,flush:r}}();function qf(e){var t=e.source,r=e.initial,o=e.dispatchEvent,n={dropTargets:[]};function i(l){o(l),n={dropTargets:l.payload.location.current.dropTargets}}a(i,"safeDispatch");var s={start:a(function(c){var u=c.nativeSetDragImage,d={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),hl.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:a(function(c){var u=c.current;hl.flush(),Bd.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:a(function(c){var u=c.current;Bd(function(){hl.flush();var d={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:d}})})},"drag"),drop:a(function(c){var u=c.current,d=c.updatedSourcePayload;hl.flush(),Bd.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return s}a(qf,"makeDispatch");var Fd={isActive:!1};function Gf(){return!Fd.isActive}a(Gf,"canStart");function J2(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}a(J2,"getNativeSetDragImage");function G2(e){var t=e.current,r=e.next;if(t.length!==r.length)return!0;for(var o=0;o<t.length;o++)if(t[o].element!==r[o].element)return!0;return!1}a(G2,"hasHierarchyChanged");function K2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!Gf())return;var i=Y2({event:t,dragType:r,getDropTargetsOver:o});Fd.isActive=!0;var s={current:i};Hd({event:t,current:i.dropTargets});var l=qf({source:r.payload,dispatchEvent:n,initial:i});function c(p){var y=G2({current:s.current.dropTargets,next:p.dropTargets});s.current=p,y&&l.dragUpdate({current:s.current})}a(c,"updateState");function u(p){var y=ni(p),h=pl(p.target)?fl({x:y.clientX,y:y.clientY}):p.target,v=o({target:h,input:y,source:r.payload,current:s.current.dropTargets});v.length&&(p.preventDefault(),Hd({event:p,current:v})),c({dropTargets:v,input:y})}a(u,"onUpdateEvent");function d(){s.current.dropTargets.length&&c({dropTargets:[],input:s.current.input}),l.drop({current:s.current,updatedSourcePayload:null}),f()}a(d,"cancel");function f(){Fd.isActive=!1,m()}a(f,"finish");var m=(0,Jf.bindAll)(window,[{type:"dragover",listener:a(function(y){u(y),l.drag({current:s.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:a(function(y){$f({dragLeave:y})&&(c({input:s.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:a(function(y){if(s.current={dropTargets:s.current.dropTargets,input:ni(y)},!s.current.dropTargets.length){d();return}y.preventDefault(),Hd({event:y,current:s.current.dropTargets}),l.drop({current:s.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(y):null}),f()},"listener")},{type:"dragend",listener:a(function(y){s.current={dropTargets:s.current.dropTargets,input:ni(y)},d()},"listener")}].concat(gl(jf({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:J2(t)})}a(K2,"start");function Hd(e){var t,r=e.event,o=e.current,n=(t=o[0])===null||t===void 0?void 0:t.dropEffect;n!=null&&r.dataTransfer&&(r.dataTransfer.dropEffect=n)}a(Hd,"setDropEffectOnEvent");function Y2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=ni(t);if(r.startedFrom==="external")return{input:n,dropTargets:[]};var i=o({input:n,source:r.payload,target:t.target,current:[]});return{input:n,dropTargets:i}}a(Y2,"getStartLocation");var Vd={canStart:Gf,start:K2};var Od=new Map;function X2(e){var t=e.typeKey,r=e.mount,o=Od.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Od.set(t,n),n}a(X2,"registerUsage");function Kf(e){var t=X2(e);return a(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Od.delete(e.typeKey))},"unregister")}a(Kf,"register");function zo(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return a(function(){t.forEach(function(n){return n()})},"cleanup")}a(zo,"combine");function bl(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}a(bl,"addAttribute");function Yf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(Yf,"ownKeys");function wn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yf(Object(r),!0).forEach(function(o){on(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yf(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(wn,"_objectSpread");function Wd(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Q2(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
184
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(Wd,"_createForOfIteratorHelper");function Q2(e,t){if(e){if(typeof e=="string")return Xf(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xf(e,t):void 0}}a(Q2,"_unsupportedIterableToArray");function Xf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(Xf,"_arrayLikeToArray");function Ud(e){return e.slice(0).reverse()}a(Ud,"copyReverse");function Qf(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function s(p){return o.set(p.element,p),function(){return o.delete(p.element)}}a(s,"addToRegistry");function l(p){if(0)var y;var h=zo(bl(p.element,{attribute:n,value:"true"}),s(p));return eo(h)}a(l,"dropTargetForConsumers");function c(p){var y,h,v,C,P=p.source,b=p.target,g=p.input,N=p.result,T=N===void 0?[]:N;if(b==null)return T;if(!(b instanceof Element))return b instanceof Node?c({source:P,target:b.parentElement,input:g,result:T}):T;var R=b.closest(i);if(R==null)return T;var E=o.get(R);if(E==null)return T;var w={input:g,source:P,element:E.element};if(E.canDrop&&!E.canDrop(w))return c({source:P,target:E.element.parentElement,input:g,result:T});var k=(y=(h=E.getData)===null||h===void 0?void 0:h.call(E,w))!==null&&y!==void 0?y:{},x=(v=(C=E.getDropEffect)===null||C===void 0?void 0:C.call(E,w))!==null&&v!==void 0?v:r,A={data:k,element:E.element,dropEffect:x,isActiveDueToStickiness:!1};return c({source:P,target:E.element.parentElement,input:g,result:[].concat(gl(T),[A])})}a(c,"getActualDropTargets");function u(p){var y=p.eventName,h=p.payload,v=Wd(h.location.current.dropTargets),C;try{for(v.s();!(C=v.n()).done;){var P,b=C.value,g=o.get(b.element),N=wn(wn({},h),{},{self:b});g==null||(P=g[y])===null||P===void 0||P.call(g,N)}}catch(T){v.e(T)}finally{v.f()}}a(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:a(function(y){var h=y.payload,v=new Set(h.location.current.dropTargets.map(function(B){return B.element})),C=new Set,P=Wd(h.location.previous.dropTargets),b;try{for(P.s();!(b=P.n()).done;){var g,N=b.value;C.add(N.element);var T=o.get(N.element),R=v.has(N.element),E=wn(wn({},h),{},{self:N});if(T==null||(g=T.onDropTargetChange)===null||g===void 0||g.call(T,E),!R){var w;T==null||(w=T.onDragLeave)===null||w===void 0||w.call(T,E)}}}catch(B){P.e(B)}finally{P.f()}var k=Wd(h.location.current.dropTargets),x;try{for(k.s();!(x=k.n()).done;){var A,M,S=x.value;if(!C.has(S.element)){var L=wn(wn({},h),{},{self:S}),I=o.get(S.element);I==null||(A=I.onDropTargetChange)===null||A===void 0||A.call(I,L),I==null||(M=I.onDragEnter)===null||M===void 0||M.call(I,L)}}}catch(B){k.e(B)}finally{k.f()}},"onDropTargetChange")};function f(p){d[p.eventName](p)}a(f,"dispatchEvent");function m(p){var y=p.source,h=p.target,v=p.input,C=p.current,P=c({source:y,target:h,input:v});if(P.length>=C.length)return P;for(var b=Ud(C),g=Ud(P),N=[],T=0;T<b.length;T++){var R,E=b[T],w=g[T];if(w!=null){N.push(w);continue}var k=N[T-1],x=b[T-1];if((k==null?void 0:k.element)!==(x==null?void 0:x.element))break;var A=o.get(E.element);if(!A)break;var M={input:v,source:y,element:A.element};if(A.canDrop&&!A.canDrop(M)||!((R=A.getIsSticky)!==null&&R!==void 0&&R.call(A,M)))break;N.push(wn(wn({},E),{},{isActiveDueToStickiness:!0}))}return Ud(N)}return a(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:f}}a(Qf,"makeDropTarget");function e0(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t0(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
185
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(e0,"_createForOfIteratorHelper");function t0(e,t){if(e){if(typeof e=="string")return e1(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e1(e,t):void 0}}a(t0,"_unsupportedIterableToArray");function e1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(e1,"_arrayLikeToArray");function t1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(t1,"ownKeys");function r0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?t1(Object(r),!0).forEach(function(o){on(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(r0,"_objectSpread");function r1(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}a(r,"tryAddToActive");function o(i){var s=r0({},i);e.add(s),r(s);function l(){e.delete(s),t&&t.active.delete(s)}return a(l,"cleanup"),eo(l)}a(o,"monitorForConsumers");function n(i){var s=i.eventName,l=i.payload;if(s==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=e0(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(v){c.e(v)}finally{c.f()}}if(t){for(var f=Array.from(t.active),m=0,p=f;m<p.length;m++){var y=p[m];if(t.active.has(y)){var h;(h=y[s])===null||h===void 0||h.call(y,l)}}s==="onDrop"&&(t.active.clear(),t=null)}}return a(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}a(r1,"makeMonitor");function o1(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,s=r1(),l=Qf({typeKey:t,defaultDropEffect:i});function c(f){o==null||o(f),l.dispatchEvent(f),s.dispatchEvent(f),n==null||n(f)}a(c,"dispatchEvent");function u(f){var m=f.event,p=f.dragType;Vd.start({event:m,dragType:p,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}a(u,"start");function d(){function f(){var m={canStart:Vd.canStart,start:u};return r(m)}return a(f,"mountAdapter"),Kf({typeKey:t,mount:f})}return a(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:s.monitorForConsumers}}a(o1,"makeAdapter");var n1=eo(a(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),i1="pdnd:android-fallback";var zd="text/plain";var a1="text/uri-list";var s1="application/vnd.pdnd";var yl=new WeakMap;function o0(e){return yl.set(e.element,e),a(function(){yl.delete(e.element)},"cleanup")}a(o0,"addToRegistry");var l1=Hf(),_d=o1({typeKey:"element",defaultDropEffect:"move",mount:a(function(t){return zo(l1.bindEvents(),(0,c1.bind)(document,{type:"dragstart",listener:a(function(o){var n,i,s,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var f=yl.get(d);if(f){var m=ni(o),p={element:f.element,dragHandle:(n=f.dragHandle)!==null&&n!==void 0?n:null,input:m};if(f.canDrag&&!f.canDrag(p)){o.preventDefault();return}if(f.dragHandle){var y=fl({x:m.clientX,y:m.clientY});if(!f.dragHandle.contains(y)){o.preventDefault();return}}var h=(i=(s=f.getInitialDataForExternal)===null||s===void 0?void 0:s.call(f,p))!==null&&i!==void 0?i:null;if(h)for(var v=0,C=Object.entries(h);v<C.length;v++){var P=ul(C[v],2),b=P[0],g=P[1];o.dataTransfer.setData(b,g!=null?g:"")}n1()&&!o.dataTransfer.types.includes(zd)&&!o.dataTransfer.types.includes(a1)&&o.dataTransfer.setData(zd,i1),o.dataTransfer.setData(s1,"");var N={element:f.element,dragHandle:(l=f.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=f.getInitialData)===null||u===void 0?void 0:u.call(f,p))!==null&&c!==void 0?c:{}},T={type:"element",payload:N,startedFrom:"internal"};t.start({event:o,dragType:T})}}}},"listener")}))},"mount"),dispatchEventToSource:a(function(t){var r,o,n=t.eventName,i=t.payload;(r=yl.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:l1.getOnPostDispatch()}),Ur=_d.dropTarget,$d=_d.monitor;function Qa(e){if(0)var t;var r=zo(_d.registerUsage(),o0(e),bl(e.element,{attribute:"draggable",value:"true"}));return eo(r)}a(Qa,"draggable");function u1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(u1,"ownKeys");function d1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?u1(Object(r),!0).forEach(function(o){on(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(d1,"_objectSpread");var n0={top:a(function(t,r){return Math.abs(r.y-t.top)},"top"),right:a(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:a(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:a(function(t,r){return Math.abs(r.x-t.left)},"left")},m1=Symbol("closestEdge");function p1(e,t){var r,o,n=t.element,i=t.input,s=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=s.map(function(f){return{edge:f,value:n0[f](c,l)}}),d=(r=(o=u.sort(function(f,m){return f.value-m.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return d1(d1({},e),{},on({},m1,d))}a(p1,"attachClosestEdge");function es(e){var t;return(t=e[m1])!==null&&t!==void 0?t:null}a(es,"extractClosestEdge");var Nc=require("@tiptap/core"),f5=require("@tiptap/react");var u5=require("@tiptap/react"),d5=require("jotai"),m5=require("react");var s5=require("@tiptap/react"),l5=require("jotai"),He=require("react"),c5=require("uuid");var Bm=require("@tiptap/extension-color");var f1=require("@tiptap/core"),g1=require("@tiptap/pm/dropcursor"),jd=f1.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,g1.dropCursor)(this.options)]}});var Hm=require("@tiptap/extension-hard-break");var h1=require("@tiptap/core"),Xi=require("@tiptap/pm/history"),i0=h1.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,Xi.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,Xi.redo)(e,t)}},addProseMirrorPlugins(){return[(0,Xi.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Fm=require("@tiptap/extension-placeholder"),Vm=require("@tiptap/extension-text-align"),Om=require("@tiptap/extension-typography"),Wm=require("@tiptap/extension-underline"),Um=require("@tiptap/starter-kit");var C1=require("@tiptap/core");var Qi=require("@tiptap/core"),a0=/^\s*>\s$/,b1=Qi.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,Qi.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,Qi.wrappingInputRule)({find:a0,type:this.type})]}});var x1=require("@tiptap/react");var y1=require("uuid");function It(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let s=`node-${(0,y1.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:s}),o=!0}return!1}),o&&e.view.dispatch(r)}a(It,"generateNodeIds");var vl=require("@tiptap/react"),Cl=require("jotai"),ea=require("react");var En=require("react/jsx-runtime"),s0=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,En.jsx)("div",{className:"courier-w-full node-element",children:(0,En.jsx)("div",{style:{zIndex:-15,position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,En.jsx)(vl.NodeViewContent,{})})}),"BlockquoteComponent"),v1=a(e=>{var l,c,u;let t=(0,Cl.useSetAtom)(gt),r=(0,Cl.useAtomValue)(ke),o=(0,ea.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,ea.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,ea.useEffect)(()=>{let d=o.current;if(!d)return;let f=a(m=>{let p=m.target;p.closest(".courier-actions-panel")||p.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",f,!0),()=>{d.removeEventListener("click",f,!0)}},[i]);let s=!e.node.content||e.node.content.size===0;return(0,En.jsx)(vl.NodeViewWrapper,{children:(0,En.jsx)("div",{ref:o,children:(0,En.jsx)(tr,{id:e.node.attrs.id,className:D(n&&"selected-element",s&&"is-empty"),editor:e.editor,children:(0,En.jsx)(s0,{...e.node.attrs})})})})},"BlockquoteComponentNode");var Pn={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},Zd=b1.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){It(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:Pn.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:Pn.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:Pn.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:Pn.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:Pn.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,C1.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let s=i.selection.from,l=i.doc.resolve(s);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,x1.ReactNodeViewRenderer)(v1)}});var A1=require("@hookform/resolvers/zod"),N1=require("react-hook-form");var ii=require("react");var zt=a(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,ii.useRef)(null),i=(0,ii.useRef)(null);return(0,ii.useEffect)(()=>{if(!e||!t)return;let l=a(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,f])=>{r.getValues(d)!==f&&r.setValue(d,f)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,ii.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:f,dispatch:m})=>{let p=f.doc.nodeAt(i.current);return(p==null?void 0:p.type.name)===o&&m?(f.setNodeMarkup(i.current,p.type,u),f.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var ai=require("jotai"),ts=require("react");var zr=a((e={},t="")=>Object.entries(e).reduce((r,[o,n])=>{let i=t?`${t}.${o}`:o;return n&&typeof n=="object"&&!Array.isArray(n)?[...r,...zr(n,i)]:[...r,i]},[]),"getFlattenedVariables");var l0={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},c0=["content","href","src","title"],T1=a((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=a(i=>{let s=i.matchAll(r);for(let l of s){let c=l[1].trim();c&&cr(c)&&t.add(c)}},"extractFromString"),n=a(i=>{let s=i;s.type==="string"&&typeof s.content=="string"&&o(s.content),s.type==="text"&&typeof s.content=="string"&&o(s.content);let l=s.type,c=l0[l];c&&c.forEach(u=>{typeof s[u]=="string"&&o(s[u])}),typeof s.if=="string"&&o(s.if),typeof s.loop=="string"&&o(s.loop),s.type==="channel"&&s.raw&&typeof s.raw=="object"&&s.raw!==null&&Object.values(s.raw).forEach(u=>{typeof u=="string"&&o(u)}),s.elements&&Array.isArray(s.elements)&&s.elements.forEach(u=>n(u)),s.locales&&typeof s.locales=="object"&&s.locales!==null&&Object.values(s.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;c0.forEach(f=>{typeof d[f]=="string"&&o(d[f])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(f=>{f&&n(f)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(f=>{typeof f=="string"&&o(f)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var u0=a(e=>{let t=(0,ai.useAtomValue)(ze),r=(0,ai.useAtomValue)(se),o=(0,ai.useAtomValue)(xn),n=(0,ai.useAtomValue)(qn),i=(0,ai.useSetAtom)(qn),s=e!=null?e:o,l=(0,ts.useMemo)(()=>{var f,m;if(!t)return[];let d=((m=(f=t.extensionManager.extensions.find(p=>p.name==="variableSuggestion"))==null?void 0:f.options)==null?void 0:m.variables)||{};return zr(d)},[t]),c=(0,ts.useMemo)(()=>{if(!r||!s)return[];let d=r.elements.find(f=>f.type==="channel"&&f.channel===s);return d?T1(d.elements||[]):[]},[r,s]),u=(0,ts.useCallback)((d,f)=>{i(m=>({...m,[d]:f}))},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u}},"useVariables");var k1=require("jotai");var rs=require("react/jsx-runtime"),Lt=a(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,rs.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,rs.jsx)("div",{className:D("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-[#F5F5F5]":"courier-border"),children:t}),(0,rs.jsx)("span",{className:"courier-text-sm courier-font-medium",children:e?r:o})]}),"BlockBase");var w1=require("lucide-react");var qd=require("react/jsx-runtime"),E1=a(({draggable:e=!1})=>(0,qd.jsx)(Lt,{draggable:e,icon:(0,qd.jsx)(w1.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var os=require("react/jsx-runtime"),d0=a(()=>(0,os.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,os.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"#171717"})}),"ButtonBlockIcon"),kn=a(({draggable:e=!1})=>(0,os.jsx)(Lt,{draggable:e,icon:(0,os.jsx)(d0,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var ns=require("react/jsx-runtime"),m0=a(()=>(0,ns.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ns.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"#171717"})}),"ColumnBlockIcon"),xl=a(({draggable:e=!1})=>(0,ns.jsx)(Lt,{draggable:e,icon:(0,ns.jsx)(m0,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var is=require("react/jsx-runtime"),p0=a(()=>(0,is.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,is.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"#171717",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),as=a(({draggable:e=!1})=>(0,is.jsx)(Lt,{draggable:e,icon:(0,is.jsx)(p0,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var ss=require("react/jsx-runtime"),f0=a(()=>(0,ss.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ss.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"#171717"})}),"DividerBlockIcon"),Mn=a(({draggable:e=!1})=>(0,ss.jsx)(Lt,{draggable:e,icon:(0,ss.jsx)(f0,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var ls=require("react/jsx-runtime"),g0=a(()=>(0,ls.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ls.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"#171717"})}),"HeadingBlockIcon"),Tl=a(({draggable:e=!1})=>(0,ls.jsx)(Lt,{draggable:e,icon:(0,ls.jsx)(g0,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var cs=require("react/jsx-runtime"),h0=a(()=>(0,cs.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,cs.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"#171717"})}),"ImageBlockIcon"),wl=a(({draggable:e=!1})=>(0,cs.jsx)(Lt,{draggable:e,icon:(0,cs.jsx)(h0,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var P1=require("lucide-react");var Jd=require("react/jsx-runtime"),El=a(({draggable:e=!1})=>(0,Jd.jsx)(Lt,{draggable:e,icon:(0,Jd.jsx)(P1.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var us=require("react/jsx-runtime"),b0=a(()=>(0,us.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,us.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"#171717"})}),"TextBlockIcon"),An=a(({draggable:e=!1})=>(0,us.jsx)(Lt,{draggable:e,icon:(0,us.jsx)(b0,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var Er=require("react/jsx-runtime"),rr=a(({type:e})=>{let t=(0,k1.useSetAtom)(gt);return(0,Er.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,Er.jsx)(Ve,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,Er.jsx)(Tl,{}),e==="text"&&(0,Er.jsx)(An,{}),e==="image"&&(0,Er.jsx)(wl,{}),e==="spacer"&&(0,Er.jsx)(El,{}),e==="divider"&&(0,Er.jsx)(Mn,{}),e==="button"&&(0,Er.jsx)(kn,{}),e==="blockquote"&&(0,Er.jsx)(E1,{}),e==="customCode"&&(0,Er.jsx)(as,{}),e==="column"&&(0,Er.jsx)(xl,{}),(0,Er.jsx)(be,{className:"courier-m-0"})]})},"FormHeader");var Nn=require("zod"),M1=Nn.z.object({paddingHorizontal:Nn.z.coerce.number().min(0),paddingVertical:Nn.z.coerce.number().min(0),backgroundColor:Nn.z.string(),borderLeftWidth:Nn.z.coerce.number().min(0),borderColor:Nn.z.string(),id:Nn.z.string().optional()});var yo=require("react/jsx-runtime"),S1=a(({element:e,editor:t})=>{let r=(0,N1.useForm)({resolver:(0,A1.zodResolver)(M1),defaultValues:{...Pn,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,yo.jsxs)(et,{...r,children:[(0,yo.jsx)(rr,{type:"blockquote"}),(0,yo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,yo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,yo.jsx)(X,{control:r.control,name:"borderColor",render:({field:n})=>(0,yo.jsxs)(K,{className:"courier-mb-3",children:[(0,yo.jsx)(Y,{children:(0,yo.jsx)(Et,{...n,defaultValue:Pn.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,yo.jsx)(Q,{})]})})]})]}):null},"BlockquoteForm");var or=require("zod"),Pl=or.z.object({label:or.z.string(),link:or.z.string().optional(),alignment:or.z.enum(["left","center","right"]),size:or.z.enum(["default","full"]),backgroundColor:or.z.string(),textColor:or.z.string(),borderWidth:or.z.number(),borderRadius:or.z.number(),borderColor:or.z.string(),padding:or.z.number(),fontWeight:or.z.enum(["normal","bold"]),fontStyle:or.z.enum(["normal","italic"]),isUnderline:or.z.boolean(),isStrike:or.z.boolean()});var R1=require("@hookform/resolvers/zod"),D1=require("react-hook-form");var kl=require("jotai"),li=Ae(require("react"),1),si=require("react");var Gd=require("react/jsx-runtime"),ds=a(({items:e,command:t,selected:r=0})=>(0,Gd.jsx)("div",{className:"courier-bg-white courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto",children:e.map((o,n)=>(0,Gd.jsx)("button",{className:D("courier-w-full courier-px-4 courier-py-2 courier-text-left hover:courier-bg-gray-100 focus:courier-bg-gray-100 focus:courier-outline-none",n===r?"courier-bg-gray-100":""),onClick:()=>t(o),children:o},n))}),"VariableSuggestions");var _o=require("react/jsx-runtime"),Pr=li.forwardRef(({as:e="Input",variables:t=[],autoResize:r,onChange:o,...n},i)=>{let[s,l]=(0,si.useState)(!1),[c,u]=(0,si.useState)(null),[d,f]=(0,si.useState)(0),m=(0,si.useRef)(null),p=(0,si.useRef)(null),y=(0,kl.useSetAtom)(qa),h=(0,kl.useSetAtom)(Cf),v=(0,kl.useSetAtom)(sl),C=li.useCallback(()=>{if(!p.current)return;let w={ref:p.current,caretPosition:p.current.selectionStart};h(w),v(w);let k={isFocused:!0,hasVariables:t.length>0,showVariablePopup:!1};y(k)},[y,h,v,t]),P=li.useCallback(w=>{var A,M;let k=w.relatedTarget&&((A=m.current)==null?void 0:A.contains(w.relatedTarget)),x=(M=w.relatedTarget)==null?void 0:M.closest("[data-variable-button]");!k&&!x&&(h({ref:null,caretPosition:null}),y({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[y,h]),b=a(w=>{let k=w.target,x={ref:k,caretPosition:k.selectionStart};h(x),v(x)},"handleSelect"),g=a(w=>{var k;if(s)switch(w.key){case"ArrowUp":w.preventDefault(),f(x=>x>0?x-1:t.length-1);break;case"ArrowDown":w.preventDefault(),f(x=>x<t.length-1?x+1:0);break;case"Enter":if(t[d]){w.preventDefault(),w.stopPropagation(),N(t[d]);return}break;case"Escape":l(!1),w.preventDefault(),w.stopPropagation();break}(k=n.onKeyDown)==null||k.call(n,w)},"handleKeyDown"),N=a(w=>{let k=p.current;if(!k)return;let x=k.value,A=k.selectionStart||0,M=x.substring(0,A-2),S=x.substring(A),L=`${M}{{${w}}}${S}`,I=A+w.length+3;if(o){let B={target:{...k,value:L}};o(B)}setTimeout(()=>{k.value=L,k.setSelectionRange(I,I)},0),l(!1)},"insertVariable"),T=a(w=>{var M;let k=w.target,x=k.value,A=k.selectionStart||0;if(x.slice(A-2,A)==="{{"&&((M=m.current)==null?void 0:M.getBoundingClientRect())){let L=x.slice(0,A),I=document.createElement("span");I.style.font=window.getComputedStyle(k).font,I.style.whiteSpace="pre-wrap",I.textContent=L,document.body.appendChild(I);let B=I.offsetWidth;document.body.removeChild(I);let F=parseInt(window.getComputedStyle(k).lineHeight),U=L.split(`
186
+ `).length-1;u({left:Math.min(B%k.offsetWidth,k.offsetWidth-200),top:U*F+30}),l(!0),f(0)}o&&o({target:k,currentTarget:k,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleChange"),R=a(w=>{var M;let k=w.target,x=k.value,A=k.selectionStart||0;if(x.slice(A-2,A)==="{{"&&((M=m.current)==null?void 0:M.getBoundingClientRect())){let L=x.slice(0,A),I=document.createElement("span");I.style.font=window.getComputedStyle(k).font,I.style.whiteSpace="pre-wrap",I.textContent=L,document.body.appendChild(I);let B=I.offsetWidth;document.body.removeChild(I);let F=parseInt(window.getComputedStyle(k).lineHeight),U=L.split(`
187
+ `).length-1;u({left:Math.min(B%k.offsetWidth,k.offsetWidth-200),top:U*F+30}),l(!0),f(0)}o&&o({target:k,currentTarget:k,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleInput");if(li.useEffect(()=>{let w=p.current;if(!w)return;let k=a(x=>{u(x.detail.cursorPosition),l(!0),f(0)},"handleShowSuggestions");return w.addEventListener("showVariableSuggestions",k),()=>{w.removeEventListener("showVariableSuggestions",k)}},[]),e==="Input"){let w={...n,ref:k=>{p.current=k,typeof i=="function"?i(k):i&&(i.current=k)},onChange:T,onInput:R,onKeyDown:g,onFocus:C,onBlur:P,onSelect:b};return(0,_o.jsxs)("div",{ref:m,className:"courier-relative",children:[(0,_o.jsx)(ye,{...w}),s&&c&&(0,_o.jsx)("div",{style:{position:"absolute",left:`${c.left}px`,top:`${c.top}px`,zIndex:50},children:(0,_o.jsx)(ds,{items:t,command:N,selected:d})})]})}let E={...n,ref:w=>{p.current=w,typeof i=="function"?i(w):i&&(i.current=w)},onChange:T,onInput:R,onKeyDown:g,onFocus:C,onBlur:P,autoResize:r,onSelect:b};return(0,_o.jsxs)("div",{ref:m,className:"courier-relative",children:[(0,_o.jsx)(_u,{...E}),s&&c&&(0,_o.jsx)("div",{style:{position:"absolute",left:`${c.left}px`,top:`${c.top}px`,zIndex:50},children:(0,_o.jsx)(ds,{items:t,command:N,selected:d})})]})});Pr.displayName="TextInput";var kr=require("react/jsx-runtime"),ms="#80849D",$o=30,Ml=a(({color:e=ms,width:t=$o,height:r=$o,...o})=>(0,kr.jsx)(G,{...o,width:t,height:r,children:(0,kr.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),Al=a(({color:e=ms,width:t=$o,height:r=$o,...o})=>(0,kr.jsx)(G,{...o,width:t,height:r,children:(0,kr.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),Nl=a(({color:e=ms,width:t=$o,height:r=$o,...o})=>(0,kr.jsx)(G,{...o,width:t,height:r,children:(0,kr.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon"),I1=a(({color:e=ms,width:t=$o,height:r=$o,...o})=>(0,kr.jsxs)(G,{...o,width:t,height:r,children:[(0,kr.jsx)("path",{d:"M10.3007 18.8007C10.0566 19.0448 10.0566 19.4405 10.3007 19.6846C10.5448 19.9287 10.9405 19.9287 11.1846 19.6846L10.3007 18.8007ZM11.1846 10.3154C10.9405 10.0713 10.5448 10.0713 10.3007 10.3154C10.0566 10.5595 10.0566 10.9552 10.3007 11.1993L11.1846 10.3154ZM8.11464 14.375C7.76946 14.375 7.48964 14.6548 7.48964 15C7.48964 15.3452 7.76946 15.625 8.11464 15.625L8.11464 14.375ZM13.5092 15.625C13.8544 15.625 14.1342 15.3452 14.1342 15C14.1342 14.6548 13.8544 14.375 13.5092 14.375L13.5092 15.625ZM11.1846 19.6846L13.9512 16.918L13.0673 16.0341L10.3007 18.8007L11.1846 19.6846ZM13.9512 13.082L11.1846 10.3154L10.3007 11.1993L13.0673 13.9659L13.9512 13.082ZM13.9512 16.918C14.2866 16.5826 14.5836 16.2875 14.7889 16.0183C15.0053 15.7347 15.178 15.4078 15.178 15L13.928 15C13.928 15.0246 13.9267 15.0877 13.7951 15.2601C13.6526 15.4469 13.4277 15.6737 13.0673 16.0341L13.9512 16.918ZM13.0673 13.9659C13.4277 14.3263 13.6526 14.5531 13.7951 14.7399C13.9267 14.9123 13.928 14.9754 13.928 15L15.178 15C15.178 14.5922 15.0053 14.2653 14.7889 13.9817C14.5836 13.7125 14.2866 13.4174 13.9512 13.082L13.0673 13.9659ZM8.11464 15.625L13.5092 15.625L13.5092 14.375L8.11464 14.375L8.11464 15.625Z",fill:e}),(0,kr.jsx)("path",{d:"M21.6993 18.8007C21.9434 19.0448 21.9434 19.4405 21.6993 19.6846C21.4552 19.9287 21.0595 19.9287 20.8154 19.6846L21.6993 18.8007ZM20.8154 10.3154C21.0595 10.0713 21.4552 10.0713 21.6993 10.3154C21.9434 10.5595 21.9434 10.9552 21.6993 11.1993L20.8154 10.3154ZM23.8854 14.375C24.2305 14.375 24.5104 14.6548 24.5104 15C24.5104 15.3452 24.2305 15.625 23.8854 15.625L23.8854 14.375ZM18.4908 15.625C18.1456 15.625 17.8658 15.3452 17.8658 15C17.8658 14.6548 18.1456 14.375 18.4908 14.375L18.4908 15.625ZM20.8154 19.6846L18.0488 16.918L18.9327 16.0341L21.6993 18.8007L20.8154 19.6846ZM18.0488 13.082L20.8154 10.3154L21.6993 11.1993L18.9327 13.9659L18.0488 13.082ZM18.0488 16.918C17.7134 16.5826 17.4164 16.2875 17.2111 16.0183C16.9947 15.7347 16.822 15.4078 16.822 15L18.072 15C18.072 15.0246 18.0733 15.0877 18.2049 15.2601C18.3474 15.4469 18.5723 15.6737 18.9327 16.0341L18.0488 16.918ZM18.9327 13.9659C18.5723 14.3263 18.3474 14.5531 18.2049 14.7399C18.0733 14.9123 18.072 14.9754 18.072 15L16.822 15C16.822 14.5922 16.9947 14.2653 17.2111 13.9817C17.4164 13.7125 17.7134 13.4174 18.0488 13.082L18.9327 13.9659ZM23.8854 15.625L18.4908 15.625L18.4908 14.375L23.8854 14.375L23.8854 15.625Z",fill:e})]}),"ButtonSizeDefaultIcon"),L1=a(({color:e=ms,width:t=$o,height:r=$o,...o})=>(0,kr.jsxs)(G,{...o,width:t,height:r,children:[(0,kr.jsx)("path",{d:"M9.18459 18.8007C9.42867 19.0448 9.42867 19.4405 9.18459 19.6846C8.94051 19.9287 8.54479 19.9287 8.30071 19.6846L9.18459 18.8007ZM8.30071 10.3154C8.54479 10.0713 8.94051 10.0713 9.18459 10.3154C9.42867 10.5595 9.42867 10.9552 9.18459 11.1993L8.30071 10.3154ZM11.3707 14.375C11.7158 14.375 11.9957 14.6548 11.9957 15C11.9957 15.3452 11.7158 15.625 11.3707 15.625L11.3707 14.375ZM5.97605 15.625C5.63087 15.625 5.35105 15.3452 5.35105 15C5.35105 14.6548 5.63087 14.375 5.97605 14.375L5.97605 15.625ZM8.30071 19.6846L5.5341 16.918L6.41799 16.0341L9.18459 18.8007L8.30071 19.6846ZM5.5341 13.082L8.30071 10.3154L9.18459 11.1993L6.41799 13.9659L5.5341 13.082ZM5.5341 16.918C5.19869 16.5826 4.90174 16.2875 4.69637 16.0183C4.48 15.7347 4.30733 15.4078 4.30733 15L5.55733 15C5.55733 15.0246 5.55861 15.0877 5.69015 15.2601C5.83269 15.4469 6.05759 15.6737 6.41799 16.0341L5.5341 16.918ZM6.41799 13.9659C6.05759 14.3263 5.83269 14.5531 5.69015 14.7399C5.55861 14.9123 5.55733 14.9754 5.55733 15L4.30733 15C4.30733 14.5922 4.48 14.2653 4.69637 13.9817C4.90174 13.7125 5.19869 13.4174 5.5341 13.082L6.41799 13.9659ZM11.3707 15.625L5.97605 15.625L5.97605 14.375L11.3707 14.375L11.3707 15.625Z",fill:e}),(0,kr.jsx)("path",{d:"M22.8154 18.8007C22.5713 19.0448 22.5713 19.4405 22.8154 19.6846C23.0595 19.9287 23.4552 19.9287 23.6993 19.6846L22.8154 18.8007ZM23.6993 10.3154C23.4552 10.0713 23.0595 10.0713 22.8154 10.3154C22.5713 10.5595 22.5713 10.9552 22.8154 11.1993L23.6993 10.3154ZM20.6293 14.375C20.2842 14.375 20.0043 14.6548 20.0043 15C20.0043 15.3452 20.2842 15.625 20.6293 15.625L20.6293 14.375ZM26.024 15.625C26.3691 15.625 26.649 15.3452 26.649 15C26.649 14.6548 26.3691 14.375 26.024 14.375L26.024 15.625ZM23.6993 19.6846L26.4659 16.918L25.582 16.0341L22.8154 18.8007L23.6993 19.6846ZM26.4659 13.082L23.6993 10.3154L22.8154 11.1993L25.582 13.9659L26.4659 13.082ZM26.4659 16.918C26.8013 16.5826 27.0983 16.2875 27.3036 16.0183C27.52 15.7347 27.6927 15.4078 27.6927 15L26.4427 15C26.4427 15.0246 26.4414 15.0877 26.3099 15.2601C26.1673 15.4469 25.9424 15.6737 25.582 16.0341L26.4659 16.918ZM25.582 13.9659C25.9424 14.3263 26.1673 14.5531 26.3099 14.7399C26.4414 14.9123 26.4427 14.9754 26.4427 15L27.6927 15C27.6927 14.5922 27.52 14.2653 27.3036 13.9817C27.0983 13.7125 26.8013 13.4174 26.4659 13.082L25.582 13.9659ZM20.6293 15.625L26.024 15.625L26.024 14.375L20.6293 14.375L20.6293 15.625Z",fill:e})]}),"ButtonSizeFullIcon");var j=require("react/jsx-runtime"),B1=a(({element:e,editor:t})=>{let r=(0,D1.useForm)({resolver:(0,R1.zodResolver)(Pl),defaultValues:{..._e,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,j.jsxs)(et,{...r,children:[(0,j.jsx)(rr,{type:"button"}),(0,j.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,j.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,j.jsx)(X,{control:r.control,name:"link",render:({field:n})=>(0,j.jsxs)(K,{children:[(0,j.jsx)(Y,{children:(0,j.jsx)(Pr,{as:"Textarea",...n,variables:[],onChange:i=>{n.onChange(i),o({...r.getValues(),link:i.target.value})}})}),(0,j.jsx)(Q,{})]})}),(0,j.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,j.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Color"}),(0,j.jsx)(X,{control:r.control,name:"textColor",render:({field:n})=>(0,j.jsxs)(K,{className:"courier-mb-4",children:[(0,j.jsx)(Y,{children:(0,j.jsx)(Et,{...n,defaultValue:_e.textColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,j.jsx)(Q,{})]})}),(0,j.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,j.jsx)(X,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,j.jsxs)(K,{className:"courier-mb-4",children:[(0,j.jsx)(Y,{children:(0,j.jsx)(Et,{...n,defaultValue:_e.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,j.jsx)(Q,{})]})}),(0,j.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,j.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,j.jsx)(X,{control:r.control,name:"padding",render:({field:n})=>(0,j.jsxs)(K,{className:"courier-mb-2",children:[(0,j.jsx)(Y,{children:(0,j.jsx)(ye,{type:"number",min:0,...n})}),(0,j.jsx)(Q,{})]})}),(0,j.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6",children:[(0,j.jsx)(X,{control:r.control,name:"alignment",render:({field:n})=>(0,j.jsxs)(K,{children:[(0,j.jsx)(Y,{children:(0,j.jsxs)(er,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},children:[(0,j.jsx)(tt,{value:"left",children:(0,j.jsx)(Ml,{})}),(0,j.jsx)(tt,{value:"center",children:(0,j.jsx)(Al,{})}),(0,j.jsx)(tt,{value:"right",children:(0,j.jsx)(Nl,{})})]})}),(0,j.jsx)(Q,{})]})}),(0,j.jsx)(X,{control:r.control,name:"size",render:({field:n})=>(0,j.jsxs)(K,{children:[(0,j.jsx)(Y,{children:(0,j.jsxs)(er,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),size:i})},children:[(0,j.jsx)(tt,{value:"default",children:(0,j.jsx)(I1,{})}),(0,j.jsx)(tt,{value:"full",children:(0,j.jsx)(L1,{})})]})}),(0,j.jsx)(Q,{})]})})]}),(0,j.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,j.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,j.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,j.jsx)(X,{control:r.control,name:"borderWidth",render:({field:n})=>(0,j.jsxs)(K,{children:[(0,j.jsx)(Y,{children:(0,j.jsx)(ye,{startAdornment:(0,j.jsx)(ho,{}),type:"number",min:0,...n})}),(0,j.jsx)(Q,{})]})}),(0,j.jsx)(X,{control:r.control,name:"borderRadius",render:({field:n})=>(0,j.jsxs)(K,{children:[(0,j.jsx)(Y,{children:(0,j.jsx)(ye,{startAdornment:(0,j.jsx)(Da,{}),type:"number",min:0,...n})}),(0,j.jsx)(Q,{})]})})]}),(0,j.jsx)(X,{control:r.control,name:"borderColor",render:({field:n})=>(0,j.jsxs)(K,{className:"courier-mb-4",children:[(0,j.jsx)(Y,{children:(0,j.jsx)(Et,{...n,defaultValue:_e.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,j.jsx)(Q,{})]})})]})]}):null},"ButtonForm");var Rl=require("@tiptap/core"),V1=require("@tiptap/react"),O1=require("uuid");var Ll=require("jotai"),$e=require("react");var ps=require("react/jsx-runtime"),Il=a(({color:e="#1D4ED8"})=>(0,ps.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,ps.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,ps.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var _t=require("react/jsx-runtime"),y0=a(e=>{if(!e)return[];let t=[],r=/\{\{([^}]+)\}\}/g,o=0,n;for(r.lastIndex=0;(n=r.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;n.index>o&&t.push({type:"text",content:e.substring(o,n.index)});let i=n[1].trim();cr(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),v0=a(({parts:e})=>{let t=(0,Ll.useAtomValue)(qn);return(0,_t.jsx)(_t.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,_t.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,_t.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,_t.jsx)(Il,{color:n?void 0:"#B45309"}),(0,_t.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),H1=a(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,$e.useRef)(null),s=(0,$e.useRef)(e),l=(0,$e.useRef)(!1),[c,u]=(0,$e.useState)(!1),d=y0(e),m=d.some(T=>T.type==="variable")&&!c;(0,$e.useLayoutEffect)(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(R=>R.nodeType===Node.TEXT_NODE).forEach(R=>R.remove())},[m,e]);let p=(0,$e.useRef)(m),y=(0,$e.useRef)(!0);(0,$e.useEffect)(()=>{if(!i.current||m){p.current=m;return}let T=p.current&&!m;p.current=m,(y.current||T||!l.current&&e!==s.current)&&(i.current.textContent=e),y.current=!1,s.current=e},[e,m]);let h=(0,$e.useCallback)(()=>{if(i.current&&!m){l.current=!0;let T=i.current.textContent||"";s.current=T,o(T),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),v=(0,$e.useCallback)(T=>{var R;if(m){T.preventDefault(),T.stopPropagation();return}if(T.key==="Enter"&&(T.preventDefault(),(R=i.current)==null||R.blur()),(T.metaKey||T.ctrlKey)&&T.key==="a"&&(T.preventDefault(),T.stopPropagation(),i.current)){let E=document.createRange();E.selectNodeContents(i.current);let w=window.getSelection();w==null||w.removeAllRanges(),w==null||w.addRange(E)}},[m]),C=(0,$e.useCallback)(()=>{u(!0)},[]),P=(0,$e.useCallback)(()=>{u(!1)},[]),b=(0,$e.useCallback)(T=>{let R=i.current;if(!R)return;if(m&&n){T.stopPropagation(),setTimeout(()=>{R.focus();let k=document.createRange();k.selectNodeContents(R),k.collapse(!1);let x=window.getSelection();x==null||x.removeAllRanges(),x==null||x.addRange(k)},0);return}if(!n)return;let E=a(()=>{let k=window.getSelection();if(!k||k.rangeCount===0)return;let x=k.getRangeAt(0),A=R.contains(x.startContainer),M=R.contains(x.endContainer);if(A&&!M){let S=document.createRange();S.selectNodeContents(R),k.removeAllRanges(),k.addRange(S)}},"checkAndConstrainSelection"),w=a(k=>{let x=R.getBoundingClientRect();(k.clientX<x.left||k.clientX>x.right||k.clientY<x.top||k.clientY>x.bottom)&&E(),document.removeEventListener("mouseup",w)},"handleMouseUp");document.addEventListener("mouseup",w)},[n,m]),g=m?(0,_t.jsx)(v0,{parts:d}):n?null:e,N=(0,$e.useCallback)(T=>{m&&n&&T.stopPropagation()},[m,n]);return(0,_t.jsx)("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:v,onPointerDown:b,onClick:N,onFocus:C,onBlur:P,className:D("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"#000000",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:g})},"EditableButton"),C0=a(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:s,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:f=!1})=>(0,_t.jsx)("div",{className:"node-element",children:(0,_t.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,_t.jsx)(H1,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:f},"button1"),(0,_t.jsx)(H1,{label:n,backgroundColor:s,textColor:l,onLabelChange:d||(()=>{}),editable:f},"button2")]})}),"ButtonRowComponent"),F1=a(e=>{let t=(0,Ll.useSetAtom)(gt),r=(0,$e.useRef)({}),o=(0,$e.useRef)({}),n=(0,$e.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Rt(e);l&&t(l)},[e,t]),i=(0,$e.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),s=(0,$e.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,$e.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,_t.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,_t.jsx)(C0,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:s,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var vo={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},Dl=Rl.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){It(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,O1.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:vo.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:vo.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:vo.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:vo.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:vo.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:vo.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:vo.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:vo.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:vo.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Rl.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,V1.ReactNodeViewRenderer)(F1,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...vo,...e}}).run()}}});var Hl=require("@tiptap/core"),z1=require("@tiptap/react"),_1=require("uuid");var W1=require("@tiptap/react"),Bl=require("jotai"),_r=require("react");var Co=require("react/jsx-runtime"),x0=a(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,_r.useRef)(null),[n,i]=(0,_r.useState)(!1);return(0,_r.useEffect)(()=>{let s=o.current;if(s)return Ur({element:s,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,Co.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:s=>{s.stopPropagation()},className:D("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,Co.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),T0=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:s,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!s.content||s.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},f={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let p=((m=s.attrs)==null?void 0:m.id)||"";return(0,Co.jsx)("div",{className:"courier-w-full node-element",style:f,children:(0,Co.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((y,h)=>(0,Co.jsx)(x0,{columnId:p,index:h,isPreviewMode:c},h))})})}return(0,Co.jsx)("div",{className:"courier-w-full node-element",style:f,children:(0,Co.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,Co.jsx)(W1.NodeViewContent,{})})})},"ColumnComponent"),U1=a(e=>{let t=(0,Bl.useSetAtom)(gt),r=(0,Bl.useAtomValue)(vr),[o,n]=(0,_r.useState)(!1),[i,s]=(0,_r.useState)(e.editor.isEditable);(0,_r.useEffect)(()=>{let f=a(()=>{s(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",f),e.editor.on("transaction",f),e.editor.on("selectionUpdate",f),()=>{e.editor.off("update",f),e.editor.off("transaction",f),e.editor.off("selectionUpdate",f)}},[e.editor]);let l=!i&&!r,c=(0,_r.useCallback)(f=>{var N,T;if(!e.editor.isEditable)return;let m=f.target,p=f.currentTarget,y=m===p,h=m.classList.contains("node-element"),v=m.classList.contains("courier-p-2"),C=m.classList.contains("courier-gap-2"),P=m.classList.contains("draggable-item"),b=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(y||h||v||C||P||b||((T=(N=m.closest("[data-node-view-content]"))==null?void 0:N.parentElement)==null?void 0:T.classList.contains("node-element"))){f.stopPropagation(),b||f.preventDefault();let R=Rt(e);if(R){e.editor.commands.blur();let E=R.attrs.id;e.editor.state.doc.descendants(w=>w.type.name==="column"&&w.attrs.id===E?(t(w),!1):!0)}}},[e,t]),u=(0,_r.useCallback)(f=>{let m=f.target,p=f.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let h=p.getBoundingClientRect(),v=f.clientY,C=30,P=v<=h.top+C||v>=h.bottom-C;n(P)},[]),d=(0,_r.useCallback)(()=>{n(!1)},[]);return(0,Co.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,Co.jsx)(T0,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var $t={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"#000000",cells:[]},Fl=Hl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){It(this.editor,this.name)},addAttributes(){return{columnsCount:{default:$t.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:$t.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:$t.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:$t.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:$t.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:$t.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:$t.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,_1.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Hl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,z1.ReactNodeViewRenderer)(U1)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||$t.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,s)=>({type:"columnCell",attrs:{index:s,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var j1=require("@hookform/resolvers/zod"),Z1=require("react-hook-form");var $r=require("zod"),$1=$r.z.object({columnsCount:$r.z.number().min(1).max(4).default(2),paddingHorizontal:$r.z.number().default(0),paddingVertical:$r.z.number().default(0),backgroundColor:$r.z.string().default("transparent"),borderWidth:$r.z.number().default(0),borderRadius:$r.z.number().default(0),borderColor:$r.z.string().default("#000000"),cells:$r.z.array($r.z.object({elements:$r.z.array($r.z.any())})).optional()});var oe=require("react/jsx-runtime"),Kd=a(({element:e,editor:t})=>{let r=(0,Z1.useForm)({resolver:(0,j1.zodResolver)($1),defaultValues:{...$t,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"column"}),n=a(i=>{if(!t||!e)return;let s=null;if(t.state.doc.descendants((p,y)=>p.attrs.id===e.attrs.id&&p.type.name==="column"?(s=y,!1):!0),s===null)return;let l=t.state.doc.nodeAt(s);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,f=l.firstChild;if(!f||f.type.name!=="columnRow"){let p=Array.from({length:i},(h,v)=>u.nodes.columnCell.create({index:v,columnId:c,isEditorMode:!1})),y=u.nodes.columnRow.create({},p);d.replaceWith(s+1,s+l.nodeSize-1,y),d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let m=f.childCount;if(i!==m){if(i>m){let p=i-m,h=s+1+f.nodeSize-1;for(let v=0;v<p;v++){let C=u.nodes.columnCell.create({index:m+v,columnId:c});d.insert(h+v*C.nodeSize,C)}}else{let p=m-i,h=s+1;for(let C=0;C<m-p;C++){let P=f.child(C);h+=P.nodeSize}let v=0;for(let C=m-p;C<m;C++){let P=f.child(C);v+=P.nodeSize}d.delete(h,h+v)}d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,oe.jsxs)(et,{...r,children:[(0,oe.jsx)(rr,{type:"column",label:"Column layout"}),(0,oe.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Columns count"}),(0,oe.jsx)(X,{control:r.control,name:"columnsCount",render:({field:i})=>(0,oe.jsxs)(K,{className:"courier-mb-4",children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(er,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:s=>{if(s){let l=Number(s);i.onChange(l),n(l)}},children:[1,2,3,4].map(s=>(0,oe.jsx)(tt,{value:s.toString(),className:"courier-w-12 courier-h-7",children:(0,oe.jsx)("span",{className:"courier-text-sm courier-font-medium",children:s})},s))})}),(0,oe.jsx)(Q,{})]})}),(0,oe.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,oe.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,oe.jsx)(X,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,oe.jsxs)(K,{children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(ye,{startAdornment:(0,oe.jsx)(Ua,{}),type:"number",min:0,...i})}),(0,oe.jsx)(Q,{})]})}),(0,oe.jsx)(X,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,oe.jsxs)(K,{children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(ye,{startAdornment:(0,oe.jsx)(Yn,{}),type:"number",min:0,...i})}),(0,oe.jsx)(Q,{})]})})]}),(0,oe.jsx)(X,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,oe.jsxs)(K,{className:"courier-mb-4",children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(Et,{...i,defaultValue:$t.backgroundColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,oe.jsx)(Q,{})]})}),(0,oe.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,oe.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,oe.jsx)(X,{control:r.control,name:"borderWidth",render:({field:i})=>(0,oe.jsxs)(K,{children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(ye,{startAdornment:(0,oe.jsx)(ho,{}),type:"number",min:0,...i})}),(0,oe.jsx)(Q,{})]})}),(0,oe.jsx)(X,{control:r.control,name:"borderRadius",render:({field:i})=>(0,oe.jsxs)(K,{children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(ye,{startAdornment:(0,oe.jsx)(Da,{}),type:"number",min:0,...i})}),(0,oe.jsx)(Q,{})]})})]}),(0,oe.jsx)(X,{control:r.control,name:"borderColor",render:({field:i})=>(0,oe.jsxs)(K,{className:"courier-mb-4",children:[(0,oe.jsx)(Y,{children:(0,oe.jsx)(Et,{...i,defaultValue:$t.borderColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,oe.jsx)(Q,{})]})})]})]}):null},"ColumnForm");var Vl=require("@tiptap/core"),Ol=Vl.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Vl.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var Ul=require("@tiptap/core"),G1=require("@tiptap/react"),zl=require("@tiptap/pm/state");var Wl=require("@tiptap/react"),Sn=require("react");var q1=require("jotai");var fs=require("react/jsx-runtime"),J1=a(e=>{let t=(0,Sn.useRef)(null),[r,o]=(0,Sn.useState)(!1),n=(0,q1.useAtomValue)(vr),i=e.node.attrs.isEditorMode===!0,[s,l]=(0,Sn.useState)(e.editor.isEditable);(0,Sn.useEffect)(()=>{let d=t.current;if(d)return Ur({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Sn.useEffect)(()=>{let d=a(()=>{l(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",d),e.editor.on("transaction",d),e.editor.on("selectionUpdate",d),()=>{e.editor.off("update",d),e.editor.off("transaction",d),e.editor.off("selectionUpdate",d)}},[e.editor]);let c=!s&&!n,u=!i&&!c;return(0,fs.jsxs)(Wl.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:D("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,fs.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,fs.jsx)(Wl.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var _l=Ul.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Ul.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,G1.ReactNodeViewRenderer)(J1)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new zl.Plugin({key:new zl.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,s)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,f=i.attrs.isEditorMode;u?f=!1:u||(f=!0),f!==i.attrs.isEditorMode&&(o.setNodeAttribute(s,"isEditorMode",f),n=!0),d&&f===!1&&(o.delete(s+1,s+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var $l=require("@tiptap/core"),Q1=require("@tiptap/react"),eg=require("uuid");var K1=require("jotai"),Y1=require("react");var gs=require("react/jsx-runtime"),w0=a(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,gs.jsx)("div",{className:"courier-w-full node-element",children:(0,gs.jsx)("div",{className:"courier-custom-code courier-py-1.5 courier-overflow-auto",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),X1=a(e=>{let t=(0,K1.useSetAtom)(gt),r=(0,Y1.useCallback)(()=>{if(!e.editor.isEditable)return;let i=Rt(e);if(i){e.editor.commands.blur();let s=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===s?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,gs.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,gs.jsx)(w0,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var nn={code:"<!-- Add your HTML code here -->"},jl=$l.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){It(this.editor,this.name)},addAttributes(){return{code:{default:nn.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,eg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,$l.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||nn.code}]]},addNodeView(){return(0,Q1.ReactNodeViewRenderer)(X1)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var jr=require("react");var tg=require("react"),rg=require("react/jsx-runtime"),Yd=(0,tg.forwardRef)(({className:e,...t},r)=>{let o=D("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,rg.jsx)("div",{className:o,ref:r,...t})});Yd.displayName="Spinner";var ci=require("react/jsx-runtime"),E0=(0,jr.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function P0(e,t){let r=(0,jr.useRef)();return(0,jr.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}a(P0,"useDebounce");var k0=a((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(s=>s.severity===8).length>0)return!1;if(!e.trim())return!0;try{if(/<[a-z][a-z0-9]*\s[^>]*$/i.test(e.trim()))return!1;let l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(v=>{var C,P;return(P=(C=v.match(/<([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:P.toLowerCase()}).filter(Boolean),p=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(v=>{var C,P;return(P=(C=v.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:P.toLowerCase()}).filter(Boolean),y=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(v=>v&&!y.includes(v));for(let v of h){let C=m.filter(b=>b===v).length,P=p.filter(b=>b===v).length;if(C!==P)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),Zl=a(({code:e,onSave:t,onValidationChange:r,validator:o=k0})=>{let n=(0,jr.useRef)(null),i=(0,jr.useRef)(null),[s,l]=(0,jr.useState)(!0),c=(0,jr.useCallback)(()=>{if(!n.current||!i.current)return!0;let m=n.current.getModel();if(!m)return!0;let p=m.getValue(),y=o(p,n.current,i.current);return y!==s&&(l(y),r==null||r(y)),y},[s,r,o]),u=P0(m=>{setTimeout(()=>{c()&&t(m)},150)},500);return(0,ci.jsx)("div",{className:"courier-h-full courier-overflow-hidden",children:(0,ci.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,ci.jsx)(jr.Suspense,{fallback:(0,ci.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,ci.jsx)(Yd,{})}),children:(0,ci.jsx)(E0,{height:"100%",defaultLanguage:"html",value:e,onChange:a(m=>{u(m||"")},"handleCodeChange"),onMount:a((m,p)=>{n.current=m,i.current=p,m.focus(),m.onDidChangeModelContent(()=>{setTimeout(c,100)}),setTimeout(c,100)},"handleEditorDidMount"),theme:"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var ng=require("@hookform/resolvers/zod"),ig=require("react-hook-form");var Xd=require("zod"),og=Xd.z.object({code:Xd.z.string()});var ag=require("react"),sg=require("jotai");var ht=require("react/jsx-runtime"),Qd=a(({element:e,editor:t})=>{let r=(0,ig.useForm)({resolver:(0,ng.zodResolver)(og),defaultValues:{...nn,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,sg.useAtom)(Vo),s=(0,ag.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,ht.jsxs)(et,{...r,children:[!n&&(0,ht.jsx)(rr,{type:"customCode"}),(0,ht.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,ht.jsx)(Ve,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,ht.jsxs)(ht.Fragment,{children:[(0,ht.jsx)(xd,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,ht.jsxs)(ht.Fragment,{children:[(0,ht.jsx)(Ba,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,ht.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,ht.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,ht.jsx)(X,{control:r.control,name:"code",render:({field:l})=>(0,ht.jsxs)(K,{className:"courier-h-full",children:[(0,ht.jsx)(Y,{children:(0,ht.jsx)(Zl,{code:l.value,onSave:c=>{l.onChange(c),s(c)},onCancel:()=>{}})}),(0,ht.jsx)(Q,{})]})})})})]})]}):null},"CustomCodeForm");var mg=require("@tiptap/core");var In=require("@tiptap/core"),ta=require("@tiptap/pm/state"),lg=In.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,In.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,In.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:l})=>{var c;if(l){let{$to:u}=s.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?s.setSelection(ta.TextSelection.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(ta.NodeSelection.create(s.doc,u.pos)):s.setSelection(ta.TextSelection.create(s.doc,u.pos));else{let f=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();f&&(s.insert(d,f),s.setSelection(ta.TextSelection.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,In.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var pg=require("@tiptap/react"),fg=require("uuid");var cg=require("jotai"),ug=require("react");var hs=require("react/jsx-runtime"),M0=a(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,hs.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,hs.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),dg=a(e=>{let t=(0,cg.useSetAtom)(gt),r=(0,ug.useCallback)(()=>{if(!e.editor.isEditable)return;let o=Rt(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,hs.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,hs.jsx)(M0,{...e.node.attrs})})},"DividerComponentNode");var Zr={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},ql={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},em=lg.extend({name:"divider",atom:!0,onCreate(){It(this.editor,this.name)},addAttributes(){return{padding:{default:Zr.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:Zr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:Zr.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:Zr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:Zr.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:Zr.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,fg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,mg.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,pg.ReactNodeViewRenderer)(dg)}});var ui=require("zod"),gg=ui.z.object({padding:ui.z.number(),color:ui.z.string(),size:ui.z.number(),radius:ui.z.number(),variant:ui.z.enum(["divider","spacer"]).default("divider")});var hg=require("@hookform/resolvers/zod"),bg=require("react-hook-form");var Be=require("react/jsx-runtime"),yg=a(({element:e,editor:t})=>{let r=(0,bg.useForm)({resolver:(0,hg.zodResolver)(gg),defaultValues:{...Zr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,Be.jsxs)(et,{...r,children:[(0,Be.jsx)(rr,{type:n}),(0,Be.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Be.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Be.jsx)(X,{control:r.control,name:"padding",render:({field:i})=>(0,Be.jsxs)(K,{children:[(0,Be.jsx)(Y,{children:(0,Be.jsx)(ye,{startAdornment:(0,Be.jsx)(Yn,{}),type:"number",...i,onChange:s=>{i.onChange(s),o({...r.getValues(),margin:s.target.value})}})}),(0,Be.jsx)(Q,{})]})}),n==="divider"&&(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,Be.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,Be.jsx)(X,{control:r.control,name:"size",render:({field:i})=>(0,Be.jsxs)(K,{className:"courier-mb-4",children:[(0,Be.jsx)(Y,{children:(0,Be.jsx)(ye,{startAdornment:(0,Be.jsx)(ho,{}),type:"number",min:0,...i,onChange:s=>{i.onChange(s),o({...r.getValues(),width:s.target.value})}})}),(0,Be.jsx)(Q,{})]})}),(0,Be.jsx)(X,{control:r.control,name:"color",render:({field:i})=>(0,Be.jsxs)(K,{className:"courier-mb-4",children:[(0,Be.jsx)(Y,{children:(0,Be.jsx)(Et,{...i,defaultValue:Zr.color,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,Be.jsx)(Q,{})]})})]})]})]})},"DividerForm");var vg=require("@tiptap/core"),Cg=vg.Node.create({name:"doc",topNode:!0,content:"block+"});var tm=Cg.extend({content:"(block)+"});var wg=require("@tiptap/core"),Eg=require("@tiptap/react");var xg=require("@tiptap/react"),di=require("react");var bs=require("react/jsx-runtime");function A0(){let[e,t]=(0,di.useState)(!1);return(0,di.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(A0,"useMountStatus");var N0=(0,di.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,di.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,bs.jsx)(xg.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:D("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),S0=a(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),Tg=a(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=A0();return(0,bs.jsx)(N0,{id:r,fadeIn:!o,children:(0,bs.jsx)("div",{className:D("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,bs.jsx)("div",{className:"courier-text-accent-foreground",children:S0(t)})})})},"DragPlaceholderComponent");var Pg=wg.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,Eg.ReactNodeViewRenderer)(Tg,{as:"div",className:"drag-placeholder-wrapper"})}});var kg=require("@tiptap/core"),Jl=require("@tiptap/pm/state"),I0=new Jl.PluginKey("file-handler"),L0=kg.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new Jl.Plugin({key:I0,props:{handleDrop:(o,n,i,s)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||s)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(f=>e==null?void 0:e.includes(f.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,s=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return s.length===0?!1:(n.preventDefault(),r&&r(this.editor,s),!0)}}})]}}),Gl=L0;var Mg=require("@tiptap/core"),Kl=require("@tiptap/pm/state");var R0=new Kl.PluginKey("fixedChannelPaste"),D0=a(e=>{let t=e.view.dom.closest(".courier-push-editor"),r=e.view.dom.closest(".courier-sms-editor"),o=e.view.dom.closest(".courier-inbox-editor");if(t||r||o)return!0;let n=e.state.doc,i=0,s=0;n.forEach(d=>{d.type.name==="paragraph"||d.type.name==="heading"?i++:d.type.name==="button"&&s++});let l=i===1&&s===0,c=i===2&&s===0,u=i>=2&&i+s<=4;return l||c||u},"isInFixedChannel"),B0=a(e=>{let t=[],r=a(o=>{if(o.type.name==="text")t.push(o.text||"");else if(o.type.name==="paragraph"||o.type.name==="heading"){let n=o.textContent||"";n.trim()&&t.push(n)}else o.content&&o.content.forEach(n=>{r(n)})},"extractTextFromNode");return e.content.forEach(o=>{r(o)}),t.filter(o=>o.trim()).join(`
188
+ `).trim()},"extractTextFromSlice"),Yl=Mg.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new Kl.Plugin({key:R0,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!D0(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading")||o.content.childCount<=1)return!1;let u=B0(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var Ng=require("@tiptap/core"),Ln=require("@tiptap/pm/state");var mi=a((e,t)=>{if(t.length===0)return!1;let r={push:()=>e.view.dom.closest(".courier-push-editor"),sms:()=>e.view.dom.closest(".courier-sms-editor"),inbox:()=>e.view.dom.closest(".courier-inbox-editor")};return t.some(o=>{var n;return(n=r[o])==null?void 0:n.call(r)})},"isInFixedChannel"),rm=a(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Ag=a(e=>{if(!rm(e))return!1;let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.node(o-1),s=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===s)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),pi=a(e=>{let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),s=r.end(o);return{start:i,end:s,node:n}}o--}return null},"getCurrentElementBounds"),Xl=a(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,s=null,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){s={node:c,depth:n};break}n--}for(;i>0;){let c=o.node(i);if(c.type.name==="paragraph"||c.type.name==="heading"){l={node:c,depth:i};break}i--}return!!(s&&l&&s.node!==l.node)},"isMultiElementSelection"),Ql=new Ln.PluginKey("fixedChannelSelection"),ec=Ng.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!mi(e,this.options.channels))return!1;let o=pi(e);if(!o)return!1;let{start:n,end:i}=o,{selection:s}=e.state;if(s.from>=n&&s.to<=i)return!1;let l=Math.max(s.from,n),c=Math.min(s.to,i);return r&&t.setSelection(Ln.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!mi(e,this.options.channels))return!1;let t=pi(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!mi(e,this.options.channels))return!1;if(rm(e)){let{selection:t}=e.state;if(pi(e)&&t.$anchor.parentOffset===0&&Ag(e))return!0}if(Xl(e)){let t=pi(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1},Delete:({editor:e})=>{if(!mi(e,this.options.channels))return!1;if(rm(e)){let{selection:t}=e.state,r=pi(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Ag(e))return!0}}if(Xl(e)){let t=pi(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1}}},addProseMirrorPlugins(){return[new Ln.Plugin({key:Ql,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!mi(o,this.options.channels))return!1;if(Xl(o)){let n=pi(o);if(n){let{start:i,end:s}=n,l=Math.max(t,i),c=Math.min(r,s),u=e.state.tr;u.setSelection(Ln.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!mi(r,this.options.channels))return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY});if(o!==null){let n=e.state.doc.resolve(o.pos),i=n.depth;for(;i>0;){let s=n.node(i);if(s.type.name==="paragraph"||s.type.name==="heading"){e.dispatch(e.state.tr.setMeta(Ql,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!mi(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&Xl(r)){let n=Ql.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,s=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(Ln.TextSelection.create(c.doc,s,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Ql)||t}}})]}});var Fg=require("@tiptap/core");var ra=require("@tiptap/core"),Sg=ra.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,ra.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,ra.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var jo=require("zod"),Ig=jo.z.object({paddingVertical:jo.z.number(),paddingHorizontal:jo.z.number(),backgroundColor:jo.z.string(),borderWidth:jo.z.number(),borderColor:jo.z.string(),textAlign:jo.z.enum(["left","center","right","justify"]).default("left"),selected:jo.z.boolean().default(!1),id:jo.z.string().optional()}),Te={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"#000000",textAlign:"left",selected:!1};var tc=require("@tiptap/react");var rc=require("jotai"),Rg=require("react");var an=require("react/jsx-runtime"),Lg=a(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:s,type:l})=>{let c=l==="heading"?`h${s}`:"p",u=(0,rc.useAtomValue)(vr);return(0,an.jsx)("div",{className:"courier-w-full node-element",children:(0,an.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,an.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,an.jsx)(tc.NodeViewContent,{as:c})})})})},"TextBlockComponent"),oc=a(e=>{let t=(0,rc.useSetAtom)(gt),r=(0,Rg.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Rt(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=Rn(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,an.jsx)(tc.NodeViewWrapper,{children:(0,an.jsx)(Lg,{...e.node.attrs,type:e.node.type.name})}):(0,an.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,an.jsx)(Lg,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var Dg=require("@hookform/resolvers/zod"),Bg=require("react-hook-form");var ve=require("react/jsx-runtime"),Hg=a(({element:e,editor:t})=>{let r=(0,Bg.useForm)({resolver:(0,Dg.zodResolver)(Ig),defaultValues:{...Te,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,ve.jsxs)(et,{...r,children:[(0,ve.jsx)(rr,{type:"text"}),(0,ve.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ve.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ve.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ve.jsx)(X,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,ve.jsxs)(K,{children:[(0,ve.jsx)(Y,{children:(0,ve.jsx)(ye,{startAdornment:(0,ve.jsx)(Ua,{}),type:"number",min:0,...n})}),(0,ve.jsx)(Q,{})]})}),(0,ve.jsx)(X,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,ve.jsxs)(K,{children:[(0,ve.jsx)(Y,{children:(0,ve.jsx)(ye,{startAdornment:(0,ve.jsx)(Yn,{}),type:"number",min:0,...n})}),(0,ve.jsx)(Q,{})]})})]}),(0,ve.jsx)(X,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ve.jsxs)(K,{className:"courier-mb-4",children:[(0,ve.jsx)(Y,{children:(0,ve.jsx)(Et,{...n,defaultValue:Te.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ve.jsx)(Q,{})]})}),(0,ve.jsx)(be,{className:"courier-mb-4"}),(0,ve.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ve.jsx)(X,{control:r.control,name:"borderWidth",render:({field:n})=>(0,ve.jsxs)(K,{className:"courier-mb-3",children:[(0,ve.jsx)(Y,{children:(0,ve.jsx)(ye,{startAdornment:(0,ve.jsx)(ho,{}),type:"number",min:0,...n})}),(0,ve.jsx)(Q,{})]})}),(0,ve.jsx)(X,{control:r.control,name:"borderColor",render:({field:n})=>(0,ve.jsxs)(K,{className:"courier-mb-4",children:[(0,ve.jsx)(Y,{children:(0,ve.jsx)(Et,{...n,defaultValue:Te.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ve.jsx)(Q,{})]})})]})]}):null},"TextBlockForm");var Vg=require("@tiptap/react");var om=Sg.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){It(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:Te.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):Te.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:Te.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):Te.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:Te.textAlign,parseHTML:t=>t.style.textAlign||Te.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:Te.backgroundColor,parseHTML:t=>t.style.backgroundColor||Te.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:Te.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):Te.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:Te.borderColor,parseHTML:t=>t.style.borderColor||Te.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,Fg.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,Vg.ReactNodeViewRenderer)(oc)}});var nc=require("@tiptap/core"),Wg=require("@tiptap/react");var nm=require("jotai"),qe=require("react");var jt=require("react/jsx-runtime"),H0=["image/png","image/jpeg","image/gif","image/webp"],F0=a(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:s,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,f]=(0,qe.useState)(!1),[m,p]=(0,qe.useState)(!0),y=(0,qe.useRef)(null),h=(0,qe.useRef)(null);(0,qe.useEffect)(()=>{e&&p(!0)},[e]),(0,qe.useEffect)(()=>{if(e&&!l&&u){let w=new Image;w.onload=()=>{try{if(!u.view||!u.state)return;let k=u.view.state.selection.from;u.chain().setNodeSelection(k).updateAttributes("imageBlock",{imageNaturalWidth:w.naturalWidth}).run()}catch{}},w.src=e}},[e,l,u]);let v=(0,qe.useCallback)(w=>{var M,S;let k=(S=(M=u==null?void 0:u.view)==null?void 0:M.dom)==null?void 0:S.closest(".ProseMirror"),x=(k==null?void 0:k.clientWidth)||1e3,A=Math.min(100,w/x*100);return Math.round(A)},[u]),C=(0,qe.useMemo)(()=>v(l),[v,l]),P=(0,qe.useCallback)(w=>H0.includes(w),[]),b=(0,qe.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&Array.from(w.dataTransfer.items).some(A=>P(A.type))&&(f(!0),w.dataTransfer.dropEffect="copy")},[P]),g=(0,qe.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),f(!1)},[]),N=(0,qe.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&Array.from(w.dataTransfer.items).some(A=>P(A.type))&&f(!0)},[P]),T=(0,qe.useCallback)(w=>{w.preventDefault(),w.stopPropagation(),f(!1);let x=Array.from(w.dataTransfer.files).find(A=>P(A.type));x&&c&&c(x)},[c,P]),R=(0,qe.useCallback)(w=>{var x;let k=(x=w.target.files)==null?void 0:x[0];k&&c&&c(k),w.target&&(w.target.value="")},[c]),E=(0,qe.useCallback)(()=>{var w;(w=y.current)==null||w.click()},[]);return _s(e)?(0,jt.jsxs)("div",{className:D("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1 courier-text-center courier-flex-wrap courier-content-center courier-p-4",d&&"courier-border-primary courier-bg-gray-50"),onDragOver:b,onDragEnter:N,onDragLeave:g,onDrop:T,style:{pointerEvents:"all"},children:[i?(0,jt.jsx)(Qn,{className:"courier-w-8 courier-h-8"}):(0,jt.jsxs)(jt.Fragment,{children:[(0,jt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,jt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:E,children:"Browse"})]}),(0,jt.jsx)("input",{ref:y,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:R})]}):(0,jt.jsx)("div",{className:"courier-w-full node-element",children:(0,jt.jsxs)("div",{className:D("courier-relative courier-p-1",(i||m)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||m)&&(0,jt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,jt.jsx)(Qn,{className:"courier-w-8 courier-h-8"})}),(0,jt.jsx)("img",{ref:h,src:e,alt:t,className:D("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||m)&&"courier-invisible"),style:{maxWidth:s===C?`${l}px`:`${s}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:w=>{if(p(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let k=u.view.state.selection.from;u.chain().setNodeSelection(k).updateAttributes("imageBlock",{imageNaturalWidth:w.target.naturalWidth}).run()},100)}catch(k){console.warn("Editor not ready for image update:",k)}},onError:()=>p(!1)})]})})},"ImageBlockComponent"),V0=["image/png","image/jpeg","image/gif","image/webp"],Og=a(e=>{let t=(0,nm.useSetAtom)(gt),r=(0,nm.useSetAtom)(ae),{uploadImage:o}=Bi(),n=(0,qe.useCallback)(l=>{var f,m,p;let c=(p=(m=(f=e.editor)==null?void 0:f.view)==null?void 0:m.dom)==null?void 0:p.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,qe.useEffect)(()=>{var c,u;let l=Rt(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let f=l.attrs.width||n(d.naturalWidth),m=Rn(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:f,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,qe.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Rt(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),s=(0,qe.useCallback)(async l=>{let c=Rn(e.getPos);Rt(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!V0.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let d=new FileReader;d.readAsDataURL(l),await new Promise((h,v)=>{d.onload=h,d.onerror=v});let m=(await o({file:l})).url,p=Rn(e.getPos);if(Rt(e)&&p!==null){let h=new Image;h.src=m,await new Promise((C,P)=>{h.onload=C,h.onerror=()=>P(new Error("Failed to load uploaded image"))});let v=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:v,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let f="Error uploading image";if(d instanceof Error){let y=d.message;y.includes("GraphQL error")?f="Server error: Could not process image":y.includes("network")||y.includes("fetch")?f="Network error: Could not upload image":f=y}r({message:f,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=Rn(e.getPos);Rt(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,jt.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,jt.jsx)(F0,{...e.node.attrs,onFileSelect:s,editor:e.editor})})},"ImageBlockView");var Pt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"#000000",isUploading:!1,imageNaturalWidth:0},ic=nc.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){It(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:Pt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:Pt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:Pt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:Pt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:Pt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:Pt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:Pt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Pt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:Pt.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,nc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,Wg.ReactNodeViewRenderer)(Og)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Pt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...Pt,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var xo=require("zod"),Ug=xo.z.object({sourcePath:xo.z.string(),link:xo.z.string().optional(),alt:xo.z.string().optional(),alignment:xo.z.enum(["left","center","right"]),width:xo.z.number().min(1).max(100),borderWidth:xo.z.number(),borderColor:xo.z.string(),isUploading:xo.z.boolean().optional(),imageNaturalWidth:xo.z.number()});var zg=require("@hookform/resolvers/zod"),_g=require("jotai"),$g=require("lucide-react"),Dt=require("react"),jg=require("react-hook-form");var _=require("react/jsx-runtime"),Zg=a(({element:e,editor:t})=>{var w,k,x,A;let r=(0,Dt.useRef)(null),o=(0,Dt.useRef)(null),n=(0,Dt.useRef)(null),[i,s]=(0,Dt.useState)(""),[l,c]=(0,Dt.useState)(!1),[u,d]=(0,Dt.useState)(((w=e==null?void 0:e.attrs)==null?void 0:w.imageNaturalWidth)||0),[f,m]=(0,Dt.useState)(!1),p=(0,_g.useSetAtom)(ae),{uploadImage:y}=Bi(),h=(0,jg.useForm)({resolver:(0,zg.zodResolver)(Ug),defaultValues:{...Pt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:v}=zt({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,Dt.useEffect)(()=>{var S;let M=(S=e==null?void 0:e.attrs)==null?void 0:S.sourcePath;if(M&&!u){let L=new Image;L.onload=()=>{d(L.naturalWidth);let I={...h.getValues(),imageNaturalWidth:L.naturalWidth};h.setValue("imageNaturalWidth",L.naturalWidth),v(I)},L.src=M}},[(k=e==null?void 0:e.attrs)==null?void 0:k.sourcePath,u,h,v]);let C=(0,Dt.useCallback)(M=>{var F,U;let S=(U=(F=t==null?void 0:t.view)==null?void 0:F.dom)==null?void 0:U.closest(".ProseMirror"),L=(S==null?void 0:S.clientWidth)||1e3;if(M||(M=u),!M)return 0;let I=Math.min(100,M/L*100);return Math.round(I)},[t,u]),P=(0,Dt.useCallback)(M=>{var S;M.preventDefault(),(S=r.current)==null||S.click()},[]),b=(0,Dt.useCallback)((M,S)=>{let L=C(M.naturalWidth);s(`${L}%`),c(!1),h.setValue("sourcePath",S),h.setValue("imageNaturalWidth",M.naturalWidth),h.setValue("width",L);let I={...h.getValues(),sourcePath:S,width:L,imageNaturalWidth:M.naturalWidth,isUploading:!1};v(I)},[h,v,C]),g=(0,Dt.useCallback)(M=>{if(!M){h.setValue("imageNaturalWidth",0),h.setValue("width",0),v({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let S=new Image;S.onload=()=>{let L=C(S.naturalWidth);h.setValue("imageNaturalWidth",S.naturalWidth),h.setValue("width",L);let I={...h.getValues(),sourcePath:M,width:L,imageNaturalWidth:S.naturalWidth};v(I)},S.onerror=()=>{console.debug("Image failed to load:",M)},S.src=M},[h,v,C]),N=(0,Dt.useCallback)(M=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{g(M)},500)},[g]);(0,Dt.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let T=((A=(x=t==null?void 0:t.extensionManager.extensions.find(M=>M.name==="variableSuggestion"))==null?void 0:x.options)==null?void 0:A.variables)||{},R=zr(T),E=h.getValues().sourcePath;return e?(0,_.jsxs)(et,{...h,children:[(0,_.jsx)(rr,{type:"image"}),(0,_.jsxs)("form",{ref:o,onChange:()=>{let M=h.getValues();v(M)},children:[(0,_.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,_.jsxs)(Xs,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,_.jsxs)(La,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,_.jsx)(zi,{value:"file",className:"courier-flex-1",children:"From file"}),(0,_.jsx)(zi,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,_.jsx)(Qs,{value:"file",children:(0,_.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,_.jsx)(Ve,{onClick:P,className:"courier-w-full",variant:"outline",type:"button",disabled:f,children:f?(0,_.jsx)(_.Fragment,{children:"Uploading..."}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)($g.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,_.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:M=>{var L;let S=(L=M.target.files)==null?void 0:L[0];if(S){m(!0),h.setValue("sourcePath",""),v({...h.getValues(),sourcePath:"",isUploading:!0});let I=new FileReader;I.onload=async()=>{try{let F=(await y({file:S})).url,U=new Image;U.onload=()=>{b(U,F),m(!1)},U.onerror=()=>{p({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),m(!1),v({...h.getValues(),isUploading:!1})},U.src=F}catch(B){console.error("Error uploading image:",B),p({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),m(!1),v({...h.getValues(),isUploading:!1})}},I.onerror=()=>{p({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),m(!1),v({...h.getValues(),isUploading:!1})},I.readAsDataURL(S)}}})]})}),(0,_.jsx)(Qs,{value:"url",children:(0,_.jsx)(X,{control:h.control,name:"sourcePath",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-mb-3",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(Pr,{as:"Textarea",...M,autoResize:!0,className:"courier-max-h-[88px]",variables:R,onChange:S=>{M.onChange(S),N(S.target.value)}})}),(0,_.jsx)(Q,{})]})})})]}),(0,_.jsx)(X,{control:h.control,name:"link",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-mb-3",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(Pr,{as:"Textarea",placeholder:"Link",...M,variables:R,onChange:S=>{M.onChange(S),v({...h.getValues(),link:S.target.value})}})}),(0,_.jsx)(Q,{})]})}),(0,_.jsx)(X,{control:h.control,name:"alt",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-mb-4",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(Pr,{as:"Textarea",...M,placeholder:"Alt text...",variables:R,onChange:S=>{M.onChange(S),v({...h.getValues(),alt:S.target.value})}})}),(0,_.jsx)(Q,{})]})}),(0,_.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,_.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let M=h.getValues().width,S=h.getValues().imageNaturalWidth,L=C(S),I=M===L,B=I?"original":"fill";return(0,_.jsxs)(er,{type:"single",value:E?B:"original",onValueChange:F=>{if(!F||F===B)return;let U=F==="fill"?100:C(S);U>0&&(h.setValue("width",U),v({...h.getValues(),width:U}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!E,children:[(0,_.jsx)(tt,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,_.jsx)(tt,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:I||!E,children:"Fill"})]})})(),(0,_.jsx)(X,{control:h.control,name:"width",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-flex-1 courier-mb-3",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(ye,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...M,value:h.getValues().sourcePath?l?i:`${M.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:S=>{c(!0),s(S.target.value)},onChange:S=>{s(S.target.value)},onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),S.currentTarget.blur())},onBlur:S=>{c(!1);let L=parseFloat(S.target.value.replace("%",""));if(!isNaN(L)){let I=Math.min(100,Math.max(1,L));M.onChange(I),v({...h.getValues(),width:Math.round(I)})}}})}),(0,_.jsx)(Q,{})]})}),(0,_.jsx)(X,{control:h.control,name:"width",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-flex-1 courier-mb-3",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(Uu,{min:0,max:100,value:[E?M.value:0],disabled:!E,onValueChange:S=>{M.onChange(S[0]),v({...h.getValues(),width:S[0]})}})}),(0,_.jsx)(Q,{})]})}),(0,_.jsx)(X,{control:h.control,name:"alignment",render:({field:M})=>(0,_.jsxs)(K,{children:[(0,_.jsx)(Y,{children:(0,_.jsxs)(er,{disabled:!E,type:"single",value:M.value,onValueChange:S=>{M.onChange(S),v({...h.getValues(),alignment:S})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,_.jsx)(tt,{size:"sm",value:"left",className:"courier-w-full",children:(0,_.jsx)(Ml,{className:"courier-h-4 courier-w-4"})}),(0,_.jsx)(tt,{size:"sm",value:"center",className:"courier-w-full",children:(0,_.jsx)(Al,{className:"courier-h-4 courier-w-4"})}),(0,_.jsx)(tt,{size:"sm",value:"right",className:"courier-w-full",children:(0,_.jsx)(Nl,{className:"courier-h-4 courier-w-4"})})]})}),(0,_.jsx)(Q,{})]})}),(0,_.jsx)(be,{className:"courier-mt-6 courier-mb-4"}),(0,_.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,_.jsx)(X,{control:h.control,name:"borderWidth",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-mb-3",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(ye,{startAdornment:(0,_.jsx)(ho,{}),type:"number",disabled:!E,min:0,...M,onChange:S=>{let L=parseInt(S.target.value)||0;M.onChange(L),v({...h.getValues(),borderWidth:L})}})}),(0,_.jsx)(Q,{})]})}),(0,_.jsx)(X,{control:h.control,name:"borderColor",render:({field:M})=>(0,_.jsxs)(K,{className:"courier-mb-4",children:[(0,_.jsx)(Y,{children:(0,_.jsx)(Et,{...M,disabled:!E,defaultValue:Pt.borderColor,onChange:S=>{M.onChange(S),v({...h.getValues(),[M.name]:S})}})}),(0,_.jsx)(Q,{})]})})]})]}):null},"ImageBlockForm");var ys=require("@tiptap/core"),qg=Ae(require("@tiptap/extension-link"),1),oa=require("@tiptap/pm/state"),im=qg.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,ys.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new oa.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:s}=i,l=s.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=s.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<s.content.size&&(c=s.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,ys.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(oa.TextSelection.create(s,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(oa.TextSelection.create(s,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new oa.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,s=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let f=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(f!==d){let m=(0,ys.getMarkRange)(n.doc.resolve(c),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:f,hasVariables:!0,originalHref:f})),s=!0)}}}}),!0)),s?i:null}})]}});var Jg=require("@hookform/resolvers/zod"),Gg=require("jotai"),sc=require("react"),Kg=require("react-hook-form"),ac=require("zod");var To=require("react/jsx-runtime"),O0=ac.z.object({href:ac.z.string(),openInNewTab:ac.z.boolean().default(!1)}),Yg=a(({editor:e,mark:t,pendingLink:r})=>{var u,d;let o=(0,Gg.useSetAtom)(ll),n=(0,sc.useRef)(null),i=(0,Kg.useForm)({resolver:(0,Jg.zodResolver)(O0),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,sc.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let s=((d=(u=e==null?void 0:e.extensionManager.extensions.find(f=>f.name==="variableSuggestion"))==null?void 0:u.options)==null?void 0:d.variables)||{},l=zr(s),c=a(async f=>{let m=f.href.trim();if(!m){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:m,target:f.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,To.jsxs)(et,{...i,children:[(0,To.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,To.jsx)("div",{className:"courier-space-y-4",children:(0,To.jsx)(X,{control:i.control,name:"href",render:({field:f})=>(0,To.jsxs)(K,{children:[(0,To.jsx)(Oo,{children:"URL"}),(0,To.jsx)(Y,{children:(0,To.jsx)(Pr,{as:"Textarea",autoResize:!0,...f,variables:l,ref:m=>{typeof f.ref=="function"&&f.ref(m),n.current=m},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),i.handleSubmit(c)())},onBlur:()=>{f.onBlur(),i.handleSubmit(c)()}})}),(0,To.jsx)(Q,{})]})})})]})},"LinkForm");var lc=require("@tiptap/core"),Xg=lc.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,lc.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var dc=require("@tiptap/react"),na=require("prosemirror-state");var sn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},uc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},W0=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),U0=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(bt=0;bt<10;bt++)sn[48+bt]=sn[96+bt]=String(bt);var bt;for(bt=1;bt<=24;bt++)sn[bt+111]="F"+bt;var bt;for(bt=65;bt<=90;bt++)sn[bt]=String.fromCharCode(bt+32),uc[bt]=String.fromCharCode(bt);var bt;for(cc in sn)uc.hasOwnProperty(cc)||(uc[cc]=sn[cc]);var cc;function Qg(e){var t=W0&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||U0&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?uc:sn)[e.keyCode]||e.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}a(Qg,"keyName");var eh=require("prosemirror-state");var z0=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function _0(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,s;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))z0?s=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),s&&(r="Meta-"+r),i&&(r="Shift-"+r),r}a(_0,"normalizeKeyName");function $0(e){let t=Object.create(null);for(let r in e)t[_0(r)]=e[r];return t}a($0,"normalize");function am(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}a(am,"modifiers");function th(e){return new eh.Plugin({props:{handleKeyDown:j0(e)}})}a(th,"keymap");function j0(e){let t=$0(e);return function(r,o){let n=Qg(o),i,s=t[am(n,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[am(n,o,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=sn[o.keyCode])&&i!=n){let l=t[am(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}a(j0,"keydownHandler");var rh=require("uuid");var sm=Xg.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){It(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,rh.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:Te.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):Te.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:Te.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):Te.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:Te.textAlign,parseHTML:e=>e.style.textAlign||Te.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:Te.backgroundColor,parseHTML:e=>e.style.backgroundColor||Te.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:Te.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):Te.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Te.borderColor,parseHTML:e=>e.style.borderColor||Te.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,dc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,dc.ReactNodeViewRenderer)(oc)},addProseMirrorPlugins(){return[th({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),s=r.end(o);if(e.from!==i||e.to!==s)return t.setSelection(na.TextSelection.create(t.doc,i,s)),!0}return!1}}),new na.Plugin({key:new na.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:s}=i,l=s.depth,c=null;for(;l>0;){let u=s.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=s.parentOffset===0,f=s.parentOffset===u.length,m=u.length===0,p=t.key==="Delete"||t.keyCode===46||t.code==="Delete",y=p?i.$from.nodeAfter:i.$from.nodeBefore,h=y!=null;if(h&&m)return!1;if(o||m&&!h||!p&&d&&!h||p&&f&&!h)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=a((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,s=n.depth,l=null;for(;s>0;){let m=n.node(s);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}s--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,f=d!=null;return f&&u?!1:c&&!f||u&&!f?!0:o?!1:(t.commands.command(({tr:m,dispatch:p})=>p?(m.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),s=r.end(o);return t.commands.setTextSelection({from:i,to:s}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}}});var oh=require("@tiptap/core"),mc=require("@tiptap/pm/state"),Z0=new mc.PluginKey("selection"),lm=oh.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,s=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,f;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let m=!1;i?m=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===s:s&&(m=l.type.name===s&&l.content.size===((f=e==null?void 0:e.content)==null?void 0:f.size)),m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new mc.Plugin({key:Z0,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),m=o.doc.resolve(d).node();if(m&&["paragraph","heading"].includes(m.type.name))return this.options.setSelectedNode(m),this.editor.commands.updateSelectionState(m),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),s=o.doc.resolve(i).node();return s&&["paragraph","heading"].includes(s.type.name)?(this.options.setSelectedNode(s),this.editor.commands.updateSelectionState(s),!0):!1}}})]}});var rt="top",kt="bottom",yt="right",ct="left",pc="auto",Dn=[rt,kt,yt,ct],ln="start",fi="end",nh="clippingParents",fc="viewport",ia="popper",ih="reference",cm=Dn.reduce(function(e,t){return e.concat([t+"-"+ln,t+"-"+fi])},[]),gc=[].concat(Dn,[pc]).reduce(function(e,t){return e.concat([t,t+"-"+ln,t+"-"+fi])},[]),q0="beforeRead",J0="read",G0="afterRead",K0="beforeMain",Y0="main",X0="afterMain",Q0="beforeWrite",ey="write",ty="afterWrite",ah=[q0,J0,G0,K0,Y0,X0,Q0,ey,ty];function Bt(e){return e?(e.nodeName||"").toLowerCase():null}a(Bt,"getNodeName");function Je(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}a(Je,"getWindow");function to(e){var t=Je(e).Element;return e instanceof t||e instanceof Element}a(to,"isElement");function Mt(e){var t=Je(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}a(Mt,"isHTMLElement");function aa(e){if(typeof ShadowRoot=="undefined")return!1;var t=Je(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}a(aa,"isShadowRoot");function ry(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!Mt(i)||!Bt(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(s){var l=n[s];l===!1?i.removeAttribute(s):i.setAttribute(s,l===!0?"":l)}))})}a(ry,"applyStyles");function oy(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach(function(o){var n=t.elements[o],i=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:r[o]),l=s.reduce(function(c,u){return c[u]="",c},{});!Mt(n)||!Bt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(c){n.removeAttribute(c)}))})}}a(oy,"effect");var vs={name:"applyStyles",enabled:!0,phase:"write",fn:ry,effect:oy,requires:["computeStyles"]};function Ht(e){return e.split("-")[0]}a(Ht,"getBasePlacement");var wo=Math.max,gi=Math.min,cn=Math.round;function sa(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}a(sa,"getUAString");function Cs(){return!/^((?!chrome|android).)*safari/i.test(sa())}a(Cs,"isLayoutViewport");function ro(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&Mt(e)&&(n=e.offsetWidth>0&&cn(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&cn(o.height)/e.offsetHeight||1);var s=to(e)?Je(e):window,l=s.visualViewport,c=!Cs()&&r,u=(o.left+(c&&l?l.offsetLeft:0))/n,d=(o.top+(c&&l?l.offsetTop:0))/i,f=o.width/n,m=o.height/i;return{width:f,height:m,top:d,right:u+f,bottom:d+m,left:u,x:u,y:d}}a(ro,"getBoundingClientRect");function hi(e){var t=ro(e),r=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:o}}a(hi,"getLayoutRect");function xs(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&aa(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}a(xs,"contains");function dr(e){return Je(e).getComputedStyle(e)}a(dr,"getComputedStyle");function um(e){return["table","td","th"].indexOf(Bt(e))>=0}a(um,"isTableElement");function Zt(e){return((to(e)?e.ownerDocument:e.document)||window.document).documentElement}a(Zt,"getDocumentElement");function un(e){return Bt(e)==="html"?e:e.assignedSlot||e.parentNode||(aa(e)?e.host:null)||Zt(e)}a(un,"getParentNode");function sh(e){return!Mt(e)||dr(e).position==="fixed"?null:e.offsetParent}a(sh,"getTrueOffsetParent");function ny(e){var t=/firefox/i.test(sa()),r=/Trident/i.test(sa());if(r&&Mt(e)){var o=dr(e);if(o.position==="fixed")return null}var n=un(e);for(aa(n)&&(n=n.host);Mt(n)&&["html","body"].indexOf(Bt(n))<0;){var i=dr(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}a(ny,"getContainingBlock");function Eo(e){for(var t=Je(e),r=sh(e);r&&um(r)&&dr(r).position==="static";)r=sh(r);return r&&(Bt(r)==="html"||Bt(r)==="body"&&dr(r).position==="static")?t:r||ny(e)||t}a(Eo,"getOffsetParent");function bi(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}a(bi,"getMainAxisFromPlacement");function yi(e,t,r){return wo(e,gi(t,r))}a(yi,"within");function lh(e,t,r){var o=yi(e,t,r);return o>r?r:o}a(lh,"withinMaxClamp");function Ts(){return{top:0,right:0,bottom:0,left:0}}a(Ts,"getFreshSideObject");function ws(e){return Object.assign({},Ts(),e)}a(ws,"mergePaddingObject");function Es(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}a(Es,"expandToHashMap");var iy=a(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,ws(typeof t!="number"?t:Es(t,Dn))},"toPaddingObject");function ay(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,s=r.modifiersData.popperOffsets,l=Ht(r.placement),c=bi(l),u=[ct,yt].indexOf(l)>=0,d=u?"height":"width";if(!(!i||!s)){var f=iy(n.padding,r),m=hi(i),p=c==="y"?rt:ct,y=c==="y"?kt:yt,h=r.rects.reference[d]+r.rects.reference[c]-s[c]-r.rects.popper[d],v=s[c]-r.rects.reference[c],C=Eo(i),P=C?c==="y"?C.clientHeight||0:C.clientWidth||0:0,b=h/2-v/2,g=f[p],N=P-m[d]-f[y],T=P/2-m[d]/2+b,R=yi(g,T,N),E=c;r.modifiersData[o]=(t={},t[E]=R,t.centerOffset=R-T,t)}}a(ay,"arrow");function sy(e){var t=e.state,r=e.options,o=r.element,n=o===void 0?"[data-popper-arrow]":o;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||xs(t.elements.popper,n)&&(t.elements.arrow=n))}a(sy,"effect");var ch={name:"arrow",enabled:!0,phase:"main",fn:ay,effect:sy,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function oo(e){return e.split("-")[1]}a(oo,"getVariation");var ly={top:"auto",right:"auto",bottom:"auto",left:"auto"};function cy(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:cn(r*n)/n||0,y:cn(o*n)/n||0}}a(cy,"roundOffsetsByDPR");function uh(e){var t,r=e.popper,o=e.popperRect,n=e.placement,i=e.variation,s=e.offsets,l=e.position,c=e.gpuAcceleration,u=e.adaptive,d=e.roundOffsets,f=e.isFixed,m=s.x,p=m===void 0?0:m,y=s.y,h=y===void 0?0:y,v=typeof d=="function"?d({x:p,y:h}):{x:p,y:h};p=v.x,h=v.y;var C=s.hasOwnProperty("x"),P=s.hasOwnProperty("y"),b=ct,g=rt,N=window;if(u){var T=Eo(r),R="clientHeight",E="clientWidth";if(T===Je(r)&&(T=Zt(r),dr(T).position!=="static"&&l==="absolute"&&(R="scrollHeight",E="scrollWidth")),T=T,n===rt||(n===ct||n===yt)&&i===fi){g=kt;var w=f&&T===N&&N.visualViewport?N.visualViewport.height:T[R];h-=w-o.height,h*=c?1:-1}if(n===ct||(n===rt||n===kt)&&i===fi){b=yt;var k=f&&T===N&&N.visualViewport?N.visualViewport.width:T[E];p-=k-o.width,p*=c?1:-1}}var x=Object.assign({position:l},u&&ly),A=d===!0?cy({x:p,y:h},Je(r)):{x:p,y:h};if(p=A.x,h=A.y,c){var M;return Object.assign({},x,(M={},M[g]=P?"0":"",M[b]=C?"0":"",M.transform=(N.devicePixelRatio||1)<=1?"translate("+p+"px, "+h+"px)":"translate3d("+p+"px, "+h+"px, 0)",M))}return Object.assign({},x,(t={},t[g]=P?h+"px":"",t[b]=C?p+"px":"",t.transform="",t))}a(uh,"mapToStyles");function uy(e){var t=e.state,r=e.options,o=r.gpuAcceleration,n=o===void 0?!0:o,i=r.adaptive,s=i===void 0?!0:i,l=r.roundOffsets,c=l===void 0?!0:l,u={placement:Ht(t.placement),variation:oo(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,uh(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,uh(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}a(uy,"computeStyles");var dh={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:uy,data:{}};var hc={passive:!0};function dy(e){var t=e.state,r=e.instance,o=e.options,n=o.scroll,i=n===void 0?!0:n,s=o.resize,l=s===void 0?!0:s,c=Je(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,hc)}),l&&c.addEventListener("resize",r.update,hc),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,hc)}),l&&c.removeEventListener("resize",r.update,hc)}}a(dy,"effect");var mh={name:"eventListeners",enabled:!0,phase:"write",fn:a(function(){},"fn"),effect:dy,data:{}};var my={left:"right",right:"left",bottom:"top",top:"bottom"};function la(e){return e.replace(/left|right|bottom|top/g,function(t){return my[t]})}a(la,"getOppositePlacement");var py={start:"end",end:"start"};function bc(e){return e.replace(/start|end/g,function(t){return py[t]})}a(bc,"getOppositeVariationPlacement");function vi(e){var t=Je(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}a(vi,"getWindowScroll");function Ci(e){return ro(Zt(e)).left+vi(e).scrollLeft}a(Ci,"getWindowScrollBarX");function dm(e,t){var r=Je(e),o=Zt(e),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(n){i=n.width,s=n.height;var u=Cs();(u||!u&&t==="fixed")&&(l=n.offsetLeft,c=n.offsetTop)}return{width:i,height:s,x:l+Ci(e),y:c}}a(dm,"getViewportRect");function mm(e){var t,r=Zt(e),o=vi(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=wo(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=wo(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-o.scrollLeft+Ci(e),c=-o.scrollTop;return dr(n||r).direction==="rtl"&&(l+=wo(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:s,x:l,y:c}}a(mm,"getDocumentRect");function xi(e){var t=dr(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}a(xi,"isScrollParent");function yc(e){return["html","body","#document"].indexOf(Bt(e))>=0?e.ownerDocument.body:Mt(e)&&xi(e)?e:yc(un(e))}a(yc,"getScrollParent");function Bn(e,t){var r;t===void 0&&(t=[]);var o=yc(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=Je(o),s=n?[i].concat(i.visualViewport||[],xi(o)?o:[]):o,l=t.concat(s);return n?l:l.concat(Bn(un(s)))}a(Bn,"listScrollParents");function ca(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}a(ca,"rectToClientRect");function fy(e,t){var r=ro(e,!1,t==="fixed");return r.top=r.top+e.clientTop,r.left=r.left+e.clientLeft,r.bottom=r.top+e.clientHeight,r.right=r.left+e.clientWidth,r.width=e.clientWidth,r.height=e.clientHeight,r.x=r.left,r.y=r.top,r}a(fy,"getInnerBoundingClientRect");function ph(e,t,r){return t===fc?ca(dm(e,r)):to(t)?fy(t,r):ca(mm(Zt(e)))}a(ph,"getClientRectFromMixedType");function gy(e){var t=Bn(un(e)),r=["absolute","fixed"].indexOf(dr(e).position)>=0,o=r&&Mt(e)?Eo(e):e;return to(o)?t.filter(function(n){return to(n)&&xs(n,o)&&Bt(n)!=="body"}):[]}a(gy,"getClippingParents");function pm(e,t,r,o){var n=t==="clippingParents"?gy(e):[].concat(t),i=[].concat(n,[r]),s=i[0],l=i.reduce(function(c,u){var d=ph(e,u,o);return c.top=wo(d.top,c.top),c.right=gi(d.right,c.right),c.bottom=gi(d.bottom,c.bottom),c.left=wo(d.left,c.left),c},ph(e,s,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}a(pm,"getClippingRect");function Ps(e){var t=e.reference,r=e.element,o=e.placement,n=o?Ht(o):null,i=o?oo(o):null,s=t.x+t.width/2-r.width/2,l=t.y+t.height/2-r.height/2,c;switch(n){case rt:c={x:s,y:t.y-r.height};break;case kt:c={x:s,y:t.y+t.height};break;case yt:c={x:t.x+t.width,y:l};break;case ct:c={x:t.x-r.width,y:l};break;default:c={x:t.x,y:t.y}}var u=n?bi(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case ln:c[u]=c[u]-(t[d]/2-r[d]/2);break;case fi:c[u]=c[u]+(t[d]/2-r[d]/2);break;default:}}return c}a(Ps,"computeOffsets");function Po(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=o===void 0?e.placement:o,i=r.strategy,s=i===void 0?e.strategy:i,l=r.boundary,c=l===void 0?nh:l,u=r.rootBoundary,d=u===void 0?fc:u,f=r.elementContext,m=f===void 0?ia:f,p=r.altBoundary,y=p===void 0?!1:p,h=r.padding,v=h===void 0?0:h,C=ws(typeof v!="number"?v:Es(v,Dn)),P=m===ia?ih:ia,b=e.rects.popper,g=e.elements[y?P:m],N=pm(to(g)?g:g.contextElement||Zt(e.elements.popper),c,d,s),T=ro(e.elements.reference),R=Ps({reference:T,element:b,strategy:"absolute",placement:n}),E=ca(Object.assign({},b,R)),w=m===ia?E:T,k={top:N.top-w.top+C.top,bottom:w.bottom-N.bottom+C.bottom,left:N.left-w.left+C.left,right:w.right-N.right+C.right},x=e.modifiersData.offset;if(m===ia&&x){var A=x[n];Object.keys(k).forEach(function(M){var S=[yt,kt].indexOf(M)>=0?1:-1,L=[rt,kt].indexOf(M)>=0?"y":"x";k[M]+=A[L]*S})}return k}a(Po,"detectOverflow");function fm(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=r.boundary,i=r.rootBoundary,s=r.padding,l=r.flipVariations,c=r.allowedAutoPlacements,u=c===void 0?gc:c,d=oo(o),f=d?l?cm:cm.filter(function(y){return oo(y)===d}):Dn,m=f.filter(function(y){return u.indexOf(y)>=0});m.length===0&&(m=f);var p=m.reduce(function(y,h){return y[h]=Po(e,{placement:h,boundary:n,rootBoundary:i,padding:s})[Ht(h)],y},{});return Object.keys(p).sort(function(y,h){return p[y]-p[h]})}a(fm,"computeAutoPlacement");function hy(e){if(Ht(e)===pc)return[];var t=la(e);return[bc(e),t,bc(t)]}a(hy,"getExpandedFallbackPlacements");function by(e){var t=e.state,r=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!0:s,c=r.fallbackPlacements,u=r.padding,d=r.boundary,f=r.rootBoundary,m=r.altBoundary,p=r.flipVariations,y=p===void 0?!0:p,h=r.allowedAutoPlacements,v=t.options.placement,C=Ht(v),P=C===v,b=c||(P||!y?[la(v)]:hy(v)),g=[v].concat(b).reduce(function(te,ee){return te.concat(Ht(ee)===pc?fm(t,{placement:ee,boundary:d,rootBoundary:f,padding:u,flipVariations:y,allowedAutoPlacements:h}):ee)},[]),N=t.rects.reference,T=t.rects.popper,R=new Map,E=!0,w=g[0],k=0;k<g.length;k++){var x=g[k],A=Ht(x),M=oo(x)===ln,S=[rt,kt].indexOf(A)>=0,L=S?"width":"height",I=Po(t,{placement:x,boundary:d,rootBoundary:f,altBoundary:m,padding:u}),B=S?M?yt:ct:M?kt:rt;N[L]>T[L]&&(B=la(B));var F=la(B),U=[];if(i&&U.push(I[A]<=0),l&&U.push(I[B]<=0,I[F]<=0),U.every(function(te){return te})){w=x,E=!1;break}R.set(x,U)}if(E)for(var W=y?3:1,O=a(function(ee){var V=g.find(function(q){var ce=R.get(q);if(ce)return ce.slice(0,ee).every(function(fe){return fe})});if(V)return w=V,"break"},"_loop"),$=W;$>0;$--){var Z=O($);if(Z==="break")break}t.placement!==w&&(t.modifiersData[o]._skip=!0,t.placement=w,t.reset=!0)}}a(by,"flip");var fh={name:"flip",enabled:!0,phase:"main",fn:by,requiresIfExists:["offset"],data:{_skip:!1}};function gh(e,t,r){return r===void 0&&(r={x:0,y:0}),{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}a(gh,"getSideOffsets");function hh(e){return[rt,yt,kt,ct].some(function(t){return e[t]>=0})}a(hh,"isAnySideFullyClipped");function yy(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,s=Po(t,{elementContext:"reference"}),l=Po(t,{altBoundary:!0}),c=gh(s,o),u=gh(l,n,i),d=hh(c),f=hh(u);t.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:f},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":f})}a(yy,"hide");var bh={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:yy};function vy(e,t,r){var o=Ht(e),n=[ct,rt].indexOf(o)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},t,{placement:e})):r,s=i[0],l=i[1];return s=s||0,l=(l||0)*n,[ct,yt].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}a(vy,"distanceAndSkiddingToXY");function Cy(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,s=gc.reduce(function(d,f){return d[f]=vy(f,t.rects,i),d},{}),l=s[t.placement],c=l.x,u=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=u),t.modifiersData[o]=s}a(Cy,"offset");var yh={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Cy};function xy(e){var t=e.state,r=e.name;t.modifiersData[r]=Ps({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}a(xy,"popperOffsets");var vh={name:"popperOffsets",enabled:!0,phase:"read",fn:xy,data:{}};function gm(e){return e==="x"?"y":"x"}a(gm,"getAltAxis");function Ty(e){var t=e.state,r=e.options,o=e.name,n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!1:s,c=r.boundary,u=r.rootBoundary,d=r.altBoundary,f=r.padding,m=r.tether,p=m===void 0?!0:m,y=r.tetherOffset,h=y===void 0?0:y,v=Po(t,{boundary:c,rootBoundary:u,padding:f,altBoundary:d}),C=Ht(t.placement),P=oo(t.placement),b=!P,g=bi(C),N=gm(g),T=t.modifiersData.popperOffsets,R=t.rects.reference,E=t.rects.popper,w=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,k=typeof w=="number"?{mainAxis:w,altAxis:w}:Object.assign({mainAxis:0,altAxis:0},w),x=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,A={x:0,y:0};if(T){if(i){var M,S=g==="y"?rt:ct,L=g==="y"?kt:yt,I=g==="y"?"height":"width",B=T[g],F=B+v[S],U=B-v[L],W=p?-E[I]/2:0,O=P===ln?R[I]:E[I],$=P===ln?-E[I]:-R[I],Z=t.elements.arrow,te=p&&Z?hi(Z):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Ts(),V=ee[S],q=ee[L],ce=yi(0,R[I],te[I]),fe=b?R[I]/2-W-ce-V-k.mainAxis:O-ce-V-k.mainAxis,me=b?-R[I]/2+W+ce+q+k.mainAxis:$+ce+q+k.mainAxis,Me=t.elements.arrow&&Eo(t.elements.arrow),mt=Me?g==="y"?Me.clientTop||0:Me.clientLeft||0:0,de=(M=x==null?void 0:x[g])!=null?M:0,Ie=B+fe-de-mt,Pe=B+me-de,nt=yi(p?gi(F,Ie):F,B,p?wo(U,Pe):U);T[g]=nt,A[g]=nt-B}if(l){var it,Yt=g==="x"?rt:ct,Xt=g==="x"?kt:yt,at=T[N],pt=N==="y"?"height":"width",br=at+v[Yt],Qt=at-v[Xt],ie=[rt,ct].indexOf(C)!==-1,yr=(it=x==null?void 0:x[N])!=null?it:0,Kr=ie?br:at-R[pt]-E[pt]-yr+k.altAxis,Yr=ie?at+R[pt]+E[pt]-yr-k.altAxis:Qt,Ho=p&&ie?lh(Kr,at,Yr):yi(p?Kr:br,at,p?Yr:Qt);T[N]=Ho,A[N]=Ho-at}t.modifiersData[o]=A}}a(Ty,"preventOverflow");var Ch={name:"preventOverflow",enabled:!0,phase:"main",fn:Ty,requiresIfExists:["offset"]};function hm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}a(hm,"getHTMLElementScroll");function bm(e){return e===Je(e)||!Mt(e)?vi(e):hm(e)}a(bm,"getNodeScroll");function wy(e){var t=e.getBoundingClientRect(),r=cn(t.width)/e.offsetWidth||1,o=cn(t.height)/e.offsetHeight||1;return r!==1||o!==1}a(wy,"isElementScaled");function ym(e,t,r){r===void 0&&(r=!1);var o=Mt(t),n=Mt(t)&&wy(t),i=Zt(t),s=ro(e,n,r),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!r)&&((Bt(t)!=="body"||xi(i))&&(l=bm(t)),Mt(t)?(c=ro(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=Ci(i))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}a(ym,"getCompositeRect");function Ey(e){var t=new Map,r=new Set,o=[];e.forEach(function(i){t.set(i.name,i)});function n(i){r.add(i.name);var s=[].concat(i.requires||[],i.requiresIfExists||[]);s.forEach(function(l){if(!r.has(l)){var c=t.get(l);c&&n(c)}}),o.push(i)}return a(n,"sort"),e.forEach(function(i){r.has(i.name)||n(i)}),o}a(Ey,"order");function vm(e){var t=Ey(e);return ah.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}a(vm,"orderModifiers");function Cm(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}a(Cm,"debounce");function xm(e){var t=e.reduce(function(r,o){var n=r[o.name];return r[o.name]=n?Object.assign({},n,o,{options:Object.assign({},n.options,o.options),data:Object.assign({},n.data,o.data)}):o,r},{});return Object.keys(t).map(function(r){return t[r]})}a(xm,"mergeByName");var xh={placement:"bottom",modifiers:[],strategy:"absolute"};function Th(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}a(Th,"areValidElements");function wh(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?xh:n;return a(function(l,c,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},xh,i),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},f=[],m=!1,p={state:d,setOptions:a(function(C){var P=typeof C=="function"?C(d.options):C;h(),d.options=Object.assign({},i,d.options,P),d.scrollParents={reference:to(l)?Bn(l):l.contextElement?Bn(l.contextElement):[],popper:Bn(c)};var b=vm(xm([].concat(o,d.options.modifiers)));return d.orderedModifiers=b.filter(function(g){return g.enabled}),y(),p.update()},"setOptions"),forceUpdate:a(function(){if(!m){var C=d.elements,P=C.reference,b=C.popper;if(Th(P,b)){d.rects={reference:ym(P,Eo(b),d.options.strategy==="fixed"),popper:hi(b)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(k){return d.modifiersData[k.name]=Object.assign({},k.data)});for(var g=0;g<d.orderedModifiers.length;g++){if(d.reset===!0){d.reset=!1,g=-1;continue}var N=d.orderedModifiers[g],T=N.fn,R=N.options,E=R===void 0?{}:R,w=N.name;typeof T=="function"&&(d=T({state:d,options:E,name:w,instance:p})||d)}}}},"forceUpdate"),update:Cm(function(){return new Promise(function(v){p.forceUpdate(),v(d)})}),destroy:a(function(){h(),m=!0},"destroy")};if(!Th(l,c))return p;p.setOptions(u).then(function(v){!m&&u.onFirstUpdate&&u.onFirstUpdate(v)});function y(){d.orderedModifiers.forEach(function(v){var C=v.name,P=v.options,b=P===void 0?{}:P,g=v.effect;if(typeof g=="function"){var N=g({state:d,name:C,instance:p,options:b}),T=a(function(){},"noopFn");f.push(N||T)}})}a(y,"runModifierEffects");function h(){f.forEach(function(v){return v()}),f=[]}return a(h,"cleanupModifierEffects"),p},"createPopper")}a(wh,"popperGenerator");var Py=[mh,vh,dh,vs,yh,fh,Ch,ch,bh],Tm=wh({defaultModifiers:Py});var ky="tippy-box",Rh="tippy-content",My="tippy-backdrop",Dh="tippy-arrow",Bh="tippy-svg-arrow",Ti={passive:!0,capture:!0},Hh=a(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function wm(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}a(wm,"getValueAtIndexOrReturn");function Nm(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}a(Nm,"isType");function Fh(e,t){return typeof e=="function"?e.apply(void 0,t):e}a(Fh,"invokeWithArgsOrReturn");function Eh(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}a(Eh,"debounce");function Ay(e){return e.split(/\s+/).filter(Boolean)}a(Ay,"splitBySpaces");function ua(e){return[].concat(e)}a(ua,"normalizeToArray");function Ph(e,t){e.indexOf(t)===-1&&e.push(t)}a(Ph,"pushIfUnique");function Ny(e){return e.filter(function(t,r){return e.indexOf(t)===r})}a(Ny,"unique");function Sy(e){return e.split("-")[0]}a(Sy,"getBasePlacement");function Cc(e){return[].slice.call(e)}a(Cc,"arrayFrom");function kh(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}a(kh,"removeUndefinedProps");function ks(){return document.createElement("div")}a(ks,"div");function xc(e){return["Element","Fragment"].some(function(t){return Nm(e,t)})}a(xc,"isElement");function Iy(e){return Nm(e,"NodeList")}a(Iy,"isNodeList");function Ly(e){return Nm(e,"MouseEvent")}a(Ly,"isMouseEvent");function Ry(e){return!!(e&&e._tippy&&e._tippy.reference===e)}a(Ry,"isReferenceElement");function Dy(e){return xc(e)?[e]:Iy(e)?Cc(e):Array.isArray(e)?e:Cc(document.querySelectorAll(e))}a(Dy,"getArrayOfElements");function Em(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}a(Em,"setTransitionDuration");function Mh(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}a(Mh,"setVisibilityState");function By(e){var t,r=ua(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}a(By,"getOwnerDocument");function Hy(e,t){var r=t.clientX,o=t.clientY;return e.every(function(n){var i=n.popperRect,s=n.popperState,l=n.props,c=l.interactiveBorder,u=Sy(s.placement),d=s.modifiersData.offset;if(!d)return!0;var f=u==="bottom"?d.top.y:0,m=u==="top"?d.bottom.y:0,p=u==="right"?d.left.x:0,y=u==="left"?d.right.x:0,h=i.top-o+f>c,v=o-i.bottom-m>c,C=i.left-r+p>c,P=r-i.right-y>c;return h||v||C||P})}a(Hy,"isCursorOutsideInteractiveBorder");function Pm(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}a(Pm,"updateTransitionEndListener");function Ah(e,t){for(var r=t;r;){var o;if(e.contains(r))return!0;r=r.getRootNode==null||(o=r.getRootNode())==null?void 0:o.host}return!1}a(Ah,"actualContains");var Zo={isTouch:!1},Nh=0;function Fy(){Zo.isTouch||(Zo.isTouch=!0,window.performance&&document.addEventListener("mousemove",Vh))}a(Fy,"onDocumentTouchStart");function Vh(){var e=performance.now();e-Nh<20&&(Zo.isTouch=!1,document.removeEventListener("mousemove",Vh)),Nh=e}a(Vh,"onDocumentMouseMove");function Vy(){var e=document.activeElement;if(Ry(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}a(Vy,"onWindowBlur");function Oy(){document.addEventListener("touchstart",Fy,Ti),window.addEventListener("blur",Vy)}a(Oy,"bindGlobalEventListeners");var Wy=typeof window!="undefined"&&typeof document!="undefined",Uy=Wy?!!window.msCrypto:!1;var zy={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},_y={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ko=Object.assign({appendTo:Hh,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:a(function(){},"onAfterUpdate"),onBeforeUpdate:a(function(){},"onBeforeUpdate"),onCreate:a(function(){},"onCreate"),onDestroy:a(function(){},"onDestroy"),onHidden:a(function(){},"onHidden"),onHide:a(function(){},"onHide"),onMount:a(function(){},"onMount"),onShow:a(function(){},"onShow"),onShown:a(function(){},"onShown"),onTrigger:a(function(){},"onTrigger"),onUntrigger:a(function(){},"onUntrigger"),onClickOutside:a(function(){},"onClickOutside"),placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},zy,_y),$y=Object.keys(ko),jy=a(function(t){var r=Object.keys(t);r.forEach(function(o){ko[o]=t[o]})},"setDefaultProps");function Oh(e){var t=e.plugins||[],r=t.reduce(function(o,n){var i=n.name,s=n.defaultValue;if(i){var l;o[i]=e[i]!==void 0?e[i]:(l=ko[i])!=null?l:s}return o},{});return Object.assign({},e,r)}a(Oh,"getExtendedPassedProps");function Zy(e,t){var r=t?Object.keys(Oh(Object.assign({},ko,{plugins:t}))):$y,o=r.reduce(function(n,i){var s=(e.getAttribute("data-tippy-"+i)||"").trim();if(!s)return n;if(i==="content")n[i]=s;else try{n[i]=JSON.parse(s)}catch{n[i]=s}return n},{});return o}a(Zy,"getDataAttributeProps");function Sh(e,t){var r=Object.assign({},t,{content:Fh(t.content,[e])},t.ignoreAttributes?{}:Zy(e,t.plugins));return r.aria=Object.assign({},ko.aria,r.aria),r.aria={expanded:r.aria.expanded==="auto"?t.interactive:r.aria.expanded,content:r.aria.content==="auto"?t.interactive?null:"describedby":r.aria.content},r}a(Sh,"evaluateProps");var qy=a(function(){return"innerHTML"},"innerHTML");function Mm(e,t){e[qy()]=t}a(Mm,"dangerouslySetInnerHTML");function Ih(e){var t=ks();return e===!0?t.className=Dh:(t.className=Bh,xc(e)?t.appendChild(e):Mm(t,e)),t}a(Ih,"createArrowElement");function Lh(e,t){xc(t.content)?(Mm(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Mm(e,t.content):e.textContent=t.content)}a(Lh,"setContent");function Am(e){var t=e.firstElementChild,r=Cc(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(Rh)}),arrow:r.find(function(o){return o.classList.contains(Dh)||o.classList.contains(Bh)}),backdrop:r.find(function(o){return o.classList.contains(My)})}}a(Am,"getChildren");function Wh(e){var t=ks(),r=ks();r.className=ky,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=ks();o.className=Rh,o.setAttribute("data-state","hidden"),Lh(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,s){var l=Am(t),c=l.box,u=l.content,d=l.arrow;s.theme?c.setAttribute("data-theme",s.theme):c.removeAttribute("data-theme"),typeof s.animation=="string"?c.setAttribute("data-animation",s.animation):c.removeAttribute("data-animation"),s.inertia?c.setAttribute("data-inertia",""):c.removeAttribute("data-inertia"),c.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?c.setAttribute("role",s.role):c.removeAttribute("role"),(i.content!==s.content||i.allowHTML!==s.allowHTML)&&Lh(u,e.props),s.arrow?d?i.arrow!==s.arrow&&(c.removeChild(d),c.appendChild(Ih(s.arrow))):c.appendChild(Ih(s.arrow)):d&&c.removeChild(d)}return a(n,"onUpdate"),{popper:t,onUpdate:n}}a(Wh,"render");Wh.$$tippy=!0;var Jy=1,vc=[],km=[];function Gy(e,t){var r=Sh(e,Object.assign({},ko,Oh(kh(t)))),o,n,i,s=!1,l=!1,c=!1,u=!1,d,f,m,p=[],y=Eh(Ie,r.interactiveDebounce),h,v=Jy++,C=null,P=Ny(r.plugins),b={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},g={id:v,reference:e,popper:ks(),popperInstance:C,props:r,state:b,plugins:P,clearDelayTimeouts:Kr,setProps:Yr,setContent:Ho,show:Un,hide:zn,hideWithInteractivity:_n,enable:ie,disable:yr,unmount:$n,destroy:jn};if(!r.render)return g;var N=r.render(g),T=N.popper,R=N.onUpdate;T.setAttribute("data-tippy-root",""),T.id="tippy-"+g.id,g.popper=T,e._tippy=g,T._tippy=g;var E=P.map(function(H){return H.fn(g)}),w=e.hasAttribute("aria-expanded");return Me(),W(),B(),F("onCreate",[g]),r.showOnCreate&&br(),T.addEventListener("mouseenter",function(){g.props.interactive&&g.state.isVisible&&g.clearDelayTimeouts()}),T.addEventListener("mouseleave",function(){g.props.interactive&&g.props.trigger.indexOf("mouseenter")>=0&&S().addEventListener("mousemove",y)}),g;function k(){var H=g.props.touch;return Array.isArray(H)?H:[H,0]}a(k,"getNormalizedTouchSettings");function x(){return k()[0]==="hold"}a(x,"getIsCustomTouchBehavior");function A(){var H;return!!((H=g.props.render)!=null&&H.$$tippy)}a(A,"getIsDefaultRenderFn");function M(){return h||e}a(M,"getCurrentTarget");function S(){var H=M().parentNode;return H?By(H):document}a(S,"getDocument");function L(){return Am(T)}a(L,"getDefaultTemplateChildren");function I(H){return g.state.isMounted&&!g.state.isVisible||Zo.isTouch||d&&d.type==="focus"?0:wm(g.props.delay,H?0:1,ko.delay)}a(I,"getDelay");function B(H){H===void 0&&(H=!1),T.style.pointerEvents=g.props.interactive&&!H?"":"none",T.style.zIndex=""+g.props.zIndex}a(B,"handleStyles");function F(H,J,ne){if(ne===void 0&&(ne=!0),E.forEach(function(he){he[H]&&he[H].apply(he,J)}),ne){var Ee;(Ee=g.props)[H].apply(Ee,J)}}a(F,"invokeHook");function U(){var H=g.props.aria;if(H.content){var J="aria-"+H.content,ne=T.id,Ee=ua(g.props.triggerTarget||e);Ee.forEach(function(he){var st=he.getAttribute(J);if(g.state.isVisible)he.setAttribute(J,st?st+" "+ne:ne);else{var Nt=st&&st.replace(ne,"").trim();Nt?he.setAttribute(J,Nt):he.removeAttribute(J)}})}}a(U,"handleAriaContentAttribute");function W(){if(!(w||!g.props.aria.expanded)){var H=ua(g.props.triggerTarget||e);H.forEach(function(J){g.props.interactive?J.setAttribute("aria-expanded",g.state.isVisible&&J===M()?"true":"false"):J.removeAttribute("aria-expanded")})}}a(W,"handleAriaExpandedAttribute");function O(){S().removeEventListener("mousemove",y),vc=vc.filter(function(H){return H!==y})}a(O,"cleanupInteractiveMouseListeners");function $(H){if(!(Zo.isTouch&&(c||H.type==="mousedown"))){var J=H.composedPath&&H.composedPath()[0]||H.target;if(!(g.props.interactive&&Ah(T,J))){if(ua(g.props.triggerTarget||e).some(function(ne){return Ah(ne,J)})){if(Zo.isTouch||g.state.isVisible&&g.props.trigger.indexOf("click")>=0)return}else F("onClickOutside",[g,H]);g.props.hideOnClick===!0&&(g.clearDelayTimeouts(),g.hide(),l=!0,setTimeout(function(){l=!1}),g.state.isMounted||V())}}}a($,"onDocumentPress");function Z(){c=!0}a(Z,"onTouchMove");function te(){c=!1}a(te,"onTouchStart");function ee(){var H=S();H.addEventListener("mousedown",$,!0),H.addEventListener("touchend",$,Ti),H.addEventListener("touchstart",te,Ti),H.addEventListener("touchmove",Z,Ti)}a(ee,"addDocumentPress");function V(){var H=S();H.removeEventListener("mousedown",$,!0),H.removeEventListener("touchend",$,Ti),H.removeEventListener("touchstart",te,Ti),H.removeEventListener("touchmove",Z,Ti)}a(V,"removeDocumentPress");function q(H,J){fe(H,function(){!g.state.isVisible&&T.parentNode&&T.parentNode.contains(T)&&J()})}a(q,"onTransitionedOut");function ce(H,J){fe(H,J)}a(ce,"onTransitionedIn");function fe(H,J){var ne=L().box;function Ee(he){he.target===ne&&(Pm(ne,"remove",Ee),J())}if(a(Ee,"listener"),H===0)return J();Pm(ne,"remove",f),Pm(ne,"add",Ee),f=Ee}a(fe,"onTransitionEnd");function me(H,J,ne){ne===void 0&&(ne=!1);var Ee=ua(g.props.triggerTarget||e);Ee.forEach(function(he){he.addEventListener(H,J,ne),p.push({node:he,eventType:H,handler:J,options:ne})})}a(me,"on");function Me(){x()&&(me("touchstart",de,{passive:!0}),me("touchend",Pe,{passive:!0})),Ay(g.props.trigger).forEach(function(H){if(H!=="manual")switch(me(H,de),H){case"mouseenter":me("mouseleave",Pe);break;case"focus":me(Uy?"focusout":"blur",nt);break;case"focusin":me("focusout",nt);break}})}a(Me,"addListeners");function mt(){p.forEach(function(H){var J=H.node,ne=H.eventType,Ee=H.handler,he=H.options;J.removeEventListener(ne,Ee,he)}),p=[]}a(mt,"removeListeners");function de(H){var J,ne=!1;if(!(!g.state.isEnabled||it(H)||l)){var Ee=((J=d)==null?void 0:J.type)==="focus";d=H,h=H.currentTarget,W(),!g.state.isVisible&&Ly(H)&&vc.forEach(function(he){return he(H)}),H.type==="click"&&(g.props.trigger.indexOf("mouseenter")<0||s)&&g.props.hideOnClick!==!1&&g.state.isVisible?ne=!0:br(H),H.type==="click"&&(s=!ne),ne&&!Ee&&Qt(H)}}a(de,"onTrigger");function Ie(H){var J=H.target,ne=M().contains(J)||T.contains(J);if(!(H.type==="mousemove"&&ne)){var Ee=pt().concat(T).map(function(he){var st,Nt=he._tippy,Xo=(st=Nt.popperInstance)==null?void 0:st.state;return Xo?{popperRect:he.getBoundingClientRect(),popperState:Xo,props:r}:null}).filter(Boolean);Hy(Ee,H)&&(O(),Qt(H))}}a(Ie,"onMouseMove");function Pe(H){var J=it(H)||g.props.trigger.indexOf("click")>=0&&s;if(!J){if(g.props.interactive){g.hideWithInteractivity(H);return}Qt(H)}}a(Pe,"onMouseLeave");function nt(H){g.props.trigger.indexOf("focusin")<0&&H.target!==M()||g.props.interactive&&H.relatedTarget&&T.contains(H.relatedTarget)||Qt(H)}a(nt,"onBlurOrFocusOut");function it(H){return Zo.isTouch?x()!==H.type.indexOf("touch")>=0:!1}a(it,"isEventListenerStopped");function Yt(){Xt();var H=g.props,J=H.popperOptions,ne=H.placement,Ee=H.offset,he=H.getReferenceClientRect,st=H.moveTransition,Nt=A()?Am(T).arrow:null,Xo=he?{getBoundingClientRect:he,contextElement:he.contextElement||M()}:e,Ea={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:a(function(pe){var Fe=pe.state;if(A()){var Xe=L(),ki=Xe.box;["placement","reference-hidden","escaped"].forEach(function(ft){ft==="placement"?ki.setAttribute("data-placement",Fe.placement):Fe.attributes.popper["data-popper-"+ft]?ki.setAttribute("data-"+ft,""):ki.removeAttribute("data-"+ft)}),Fe.attributes.popper={}}},"fn")},re=[{name:"offset",options:{offset:Ee}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!st}},Ea];A()&&Nt&&re.push({name:"arrow",options:{element:Nt,padding:3}}),re.push.apply(re,(J==null?void 0:J.modifiers)||[]),g.popperInstance=Tm(Xo,T,Object.assign({},J,{placement:ne,onFirstUpdate:m,modifiers:re}))}a(Yt,"createPopperInstance");function Xt(){g.popperInstance&&(g.popperInstance.destroy(),g.popperInstance=null)}a(Xt,"destroyPopperInstance");function at(){var H=g.props.appendTo,J,ne=M();g.props.interactive&&H===Hh||H==="parent"?J=ne.parentNode:J=Fh(H,[ne]),J.contains(T)||J.appendChild(T),g.state.isMounted=!0,Yt()}a(at,"mount");function pt(){return Cc(T.querySelectorAll("[data-tippy-root]"))}a(pt,"getNestedPopperTree");function br(H){g.clearDelayTimeouts(),H&&F("onTrigger",[g,H]),ee();var J=I(!0),ne=k(),Ee=ne[0],he=ne[1];Zo.isTouch&&Ee==="hold"&&he&&(J=he),J?o=setTimeout(function(){g.show()},J):g.show()}a(br,"scheduleShow");function Qt(H){if(g.clearDelayTimeouts(),F("onUntrigger",[g,H]),!g.state.isVisible){V();return}if(!(g.props.trigger.indexOf("mouseenter")>=0&&g.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(H.type)>=0&&s)){var J=I(!1);J?n=setTimeout(function(){g.state.isVisible&&g.hide()},J):i=requestAnimationFrame(function(){g.hide()})}}a(Qt,"scheduleHide");function ie(){g.state.isEnabled=!0}a(ie,"enable");function yr(){g.hide(),g.state.isEnabled=!1}a(yr,"disable");function Kr(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}a(Kr,"clearDelayTimeouts");function Yr(H){if(!g.state.isDestroyed){F("onBeforeUpdate",[g,H]),mt();var J=g.props,ne=Sh(e,Object.assign({},J,kh(H),{ignoreAttributes:!0}));g.props=ne,Me(),J.interactiveDebounce!==ne.interactiveDebounce&&(O(),y=Eh(Ie,ne.interactiveDebounce)),J.triggerTarget&&!ne.triggerTarget?ua(J.triggerTarget).forEach(function(Ee){Ee.removeAttribute("aria-expanded")}):ne.triggerTarget&&e.removeAttribute("aria-expanded"),W(),B(),R&&R(J,ne),g.popperInstance&&(Yt(),pt().forEach(function(Ee){requestAnimationFrame(Ee._tippy.popperInstance.forceUpdate)})),F("onAfterUpdate",[g,H])}}a(Yr,"setProps");function Ho(H){g.setProps({content:H})}a(Ho,"setContent");function Un(){var H=g.state.isVisible,J=g.state.isDestroyed,ne=!g.state.isEnabled,Ee=Zo.isTouch&&!g.props.touch,he=wm(g.props.duration,0,ko.duration);if(!(H||J||ne||Ee)&&!M().hasAttribute("disabled")&&(F("onShow",[g],!1),g.props.onShow(g)!==!1)){if(g.state.isVisible=!0,A()&&(T.style.visibility="visible"),B(),ee(),g.state.isMounted||(T.style.transition="none"),A()){var st=L(),Nt=st.box,Xo=st.content;Em([Nt,Xo],0)}m=a(function(){var re;if(!(!g.state.isVisible||u)){if(u=!0,T.offsetHeight,T.style.transition=g.props.moveTransition,A()&&g.props.animation){var ue=L(),pe=ue.box,Fe=ue.content;Em([pe,Fe],he),Mh([pe,Fe],"visible")}U(),W(),Ph(km,g),(re=g.popperInstance)==null||re.forceUpdate(),F("onMount",[g]),g.props.animation&&A()&&ce(he,function(){g.state.isShown=!0,F("onShown",[g])})}},"onFirstUpdate"),at()}}a(Un,"show");function zn(){var H=!g.state.isVisible,J=g.state.isDestroyed,ne=!g.state.isEnabled,Ee=wm(g.props.duration,1,ko.duration);if(!(H||J||ne)&&(F("onHide",[g],!1),g.props.onHide(g)!==!1)){if(g.state.isVisible=!1,g.state.isShown=!1,u=!1,s=!1,A()&&(T.style.visibility="hidden"),O(),V(),B(!0),A()){var he=L(),st=he.box,Nt=he.content;g.props.animation&&(Em([st,Nt],Ee),Mh([st,Nt],"hidden"))}U(),W(),g.props.animation?A()&&q(Ee,g.unmount):g.unmount()}}a(zn,"hide");function _n(H){S().addEventListener("mousemove",y),Ph(vc,y),y(H)}a(_n,"hideWithInteractivity");function $n(){g.state.isVisible&&g.hide(),g.state.isMounted&&(Xt(),pt().forEach(function(H){H._tippy.unmount()}),T.parentNode&&T.parentNode.removeChild(T),km=km.filter(function(H){return H!==g}),g.state.isMounted=!1,F("onHidden",[g]))}a($n,"unmount");function jn(){g.state.isDestroyed||(g.clearDelayTimeouts(),g.unmount(),mt(),delete e._tippy,g.state.isDestroyed=!0,F("onDestroy",[g]))}a(jn,"destroy")}a(Gy,"createTippy");function Ms(e,t){t===void 0&&(t={});var r=ko.plugins.concat(t.plugins||[]);Oy();var o=Object.assign({},t,{plugins:r}),n=Dy(e);if(0)var i,s;var l=n.reduce(function(c,u){var d=u&&Gy(u,o);return d&&c.push(d),c},[]);return xc(e)?l[0]:l}a(Ms,"tippy");Ms.defaultProps=ko;Ms.setDefaultProps=jy;Ms.currentInput=Zo;var sL=Object.assign({},vs,{effect:a(function(t){var r=t.state,o={popper:{position:r.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(r.elements.popper.style,o.popper),r.styles=o,r.elements.arrow&&Object.assign(r.elements.arrow.style,o.arrow)},"effect")});Ms.setDefaultProps({render:Wh});var Uh=Ms;var zh=require("react"),_h=require("react/jsx-runtime"),Sm=(0,zh.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let s=D("courier-bg-white courier-rounded-lg dark:courier-bg-black",r?"courier-shadow-sm":"",o?"courier-border courier-border-border dark:courier-border-neutral-800":"",t);return(0,_h.jsx)("div",{className:s,...n,ref:i,children:e})});Sm.displayName="Surface";var Tc=require("@tiptap/core"),Jh=require("@tiptap/react"),Gh=require("@tiptap/suggestion");var $h=require("@tiptap/react");var Mo={items:({query:e,editor:t})=>{var n,i;let r=((i=(n=t.extensionManager.extensions.find(s=>s.name==="variableSuggestion"))==null?void 0:n.options)==null?void 0:i.variables)||{};return zr(r).filter(s=>s.toLowerCase().includes(e.toLowerCase()))},char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,decorationTag:"span",decorationClass:"variable-suggestion",command:({editor:e,range:t,props:r})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:r}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,r=null,o=a((i,s)=>{e==null||e.updateProps({...i,selected:s})},"updateComponent"),n=a(i=>{var c,u;if(!r)return!1;let l=((c=Mo.items)==null?void 0:c.call(Mo,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return l?((u=Mo.command)==null||u.call(Mo,{editor:r.editor,range:r.range,props:l}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new $h.ReactRenderer(ds,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=Uh(i.editor.options.element,{getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect},appendTo:()=>i.editor.options.element,content:e==null?void 0:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",theme:"variable"}),e!=null&&e.element&&e.element.focus())},onUpdate(i){r=i,e==null||e.updateProps({...i,selected:e.props.selected}),i.clientRect&&(t==null||t.setProps({getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect}}))},onKeyDown(i){var c;if(!e||!r)return!1;let s=(c=Mo.items)==null?void 0:c.call(Mo,{query:e.props.query||"",editor:e.props.editor}),l=e.props.selected;if(i.event.key==="ArrowUp"){let u=(l-1+s.length)%s.length;return o(r,u),!0}if(i.event.key==="ArrowDown"){let u=(l+1)%s.length;return o(r,u),!0}return i.event.key==="Enter"?(i.event.preventDefault(),n(l)):i.event.key==="Escape"?(r.editor.chain().focus().deleteRange(r.range).run(),!0):!1},onExit(){t==null||t.destroy(),e==null||e.destroy(),r=null}}}};var jh=require("@tiptap/react"),ma=require("react"),Zh=require("jotai");var da=require("react/jsx-runtime"),qh=a(({node:e,editor:t,getPos:r})=>{let n=(0,Zh.useAtomValue)(qn)[e.attrs.id],[i,s]=(0,ma.useState)(!1),l=(0,ma.useCallback)(()=>{if(typeof r=="function")try{let f=r();if(f==null){s(!1);return}let p=t.state.doc.resolve(f).parent;s(p&&p.type.name==="button")}catch{s(!1)}else s(!1)},[t,r]);(0,ma.useEffect)(()=>{l();let f=a(()=>{l()},"handleUpdate");return t.on("update",f),t.on("selectionUpdate",f),()=>{t.off("update",f),t.off("selectionUpdate",f)}},[t,l]);let c=n?"#EFF6FF":"#FFFBEB",u=n?"#BFDBFE":"#FDE68A",d=n?void 0:"#B45309";return(0,da.jsx)(jh.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,da.jsxs)("span",{className:`courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] ${i?"courier-variable-in-button":""}`,style:{backgroundColor:c,borderColor:u,...i&&{color:"#000000"}},children:[(0,da.jsx)(Il,{color:d}),(0,da.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:i?{color:"#000000"}:void 0,children:[e.attrs.id,n?`="${n}"`:""]})]})})},"VariableView");var Im=Tc.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,Jh.ReactNodeViewRenderer)(qh)}}),Lm=Tc.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...Mo}}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[(0,Gh.Suggestion)({editor:this.editor,...this.options.suggestion})]}});var Kh=require("@tiptap/core"),Yh=require("@tiptap/pm/state"),wc=require("@tiptap/pm/model");var Rm=Kh.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new Yh.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return cr(n)?`<span data-variable="true" data-id="${n}"></span>`:r}),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],s=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>s){let u=e.substring(s,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&cr(c))i.push(n.nodes.variable.create({id:c}));else{let u=l[0];i.push(n.text(u))}s=l.index+l[0].length}if(s<e.length){let c=e.substring(s);c&&i.push(n.text(c))}if(i.length>0){let c=wc.Fragment.from(i),u=new wc.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var Xh=require("@tiptap/core"),Ec=require("@tiptap/pm/state");var Dm=Xh.Extension.create({name:"variableTypeHandler",addProseMirrorPlugins(){return[new Ec.Plugin({key:new Ec.PluginKey("variableTypeHandler"),appendTransaction:(e,t,r)=>{if(!e.some(u=>u.docChanged))return null;let{schema:n,doc:i}=r,s=/\{\{([^}]+)\}\}/g,l=[];if(i.descendants((u,d)=>{if(u.isText&&u.text){let f;for(s.lastIndex=0;(f=s.exec(u.text))!==null;){let m=f[1].trim();m&&cr(m)&&l.push({from:d+f.index,to:d+f.index+f[0].length,variableName:m})}}}),l.length===0)return null;let c=r.tr;for(let u=l.length-1;u>=0;u--){let{from:d,to:f,variableName:m}=l[u],p=c.doc.nodeAt(d);p&&p.isText&&n.nodes.variable&&c.replaceWith(d,f,n.nodes.variable.create({id:m}))}return c.docChanged?c:null}})]}});var Qh=require("uuid");var Ky=a((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),e5=a((e,t,r,o,n,i)=>{let s=`node-${(0,Qh.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...Te,...o,id:s},i),paragraph:()=>e.schema.nodes.paragraph.create({...Te,...o,id:s},i),text:()=>e.schema.nodes.paragraph.create({...Te,...o,id:s},i),spacer:()=>e.schema.nodes.divider.create({...ql,...o,id:s}),divider:()=>e.schema.nodes.divider.create({...Zr,...o,id:s}),button:()=>e.schema.nodes.button.create({..._e,...o,id:s},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...Pt,...o,id:s}),image:()=>e.schema.nodes.imageBlock.create({...Pt,...o,id:s}),customCode:()=>e.schema.nodes.customCode.create({...nn,...o,id:s}),column:()=>e.schema.nodes.column.create({...$t,...o,id:s})}[t];if(c)try{let u=e.state.tr,d=c();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=Ky(e,s);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let f=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(f)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:s},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let f=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(f)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return s},"createOrDuplicateNode");var Rn=a(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),Rt=a(e=>{let t=Rn(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var t5=require("lucide-react"),r5=require("react"),zm=require("react/jsx-runtime"),o5=(0,r5.forwardRef)((e,t)=>(0,zm.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:D("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,zm.jsx)(t5.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-ring courier-fill-ring courier-pointer-events-none"})}));var Pc=require("jotai"),Mr=require("react"),a5=require("uuid");var n5=require("react");var i5=a((e,t,r)=>(0,n5.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var kc=a((e,t,r)=>{let o=(0,Pc.useSetAtom)(gt),n=(0,Pc.useAtomValue)(ke),i=i5(t,e,r),s=(0,Mr.useCallback)(b=>{let g=-1;return e.state.doc.descendants((N,T)=>{var R;return((R=N.attrs)==null?void 0:R.id)===b?(g=T,!1):!0}),g},[e]),l=(0,Mr.useCallback)((b,g)=>{var N,T,R;if(((N=n==null?void 0:n.type)==null?void 0:N.name)==="button"&&((T=n.attrs)!=null&&T.id)){let E=n.attrs.id,w=s(E);if(w>=0){let k=e.state.tr;return k.setNodeMarkup(w,void 0,{...(R=e.state.doc.nodeAt(w))==null?void 0:R.attrs,[b]:g}),e.view.dispatch(k),setTimeout(()=>{let x=s(E);if(x>=0){let A=e.state.doc.nodeAt(x);A&&o(A)}},0),!0}}return!1},[e,n,s,o]),c=(0,Mr.useCallback)(()=>{var b,g;if(((b=n==null?void 0:n.type)==null?void 0:b.name)==="button"&&((g=n.attrs)!=null&&g.id)){let N=n.attrs.id,T=s(N);if(T>=0){let R=e.state.doc.nodeAt(T);if(!R)return!1;let E={...R.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},w=e.state.tr;return w.setNodeMarkup(T,void 0,E),e.view.dispatch(w),setTimeout(()=>{let k=s(N);if(k>=0){let x=e.state.doc.nodeAt(k);x&&o(x)}},0),!0}}return!1},[e,n,s,o]),u=(0,Mr.useCallback)(()=>{var b;if(((b=n==null?void 0:n.type)==null?void 0:b.name)==="button"){let g=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",g))return!0}if(i&&r){let g=i.getRuleForItem("bold");if(g&&g.action.type==="toggle_off"){let N=e.chain().focus();return g.action.targets.forEach(T=>{T==="italic"&&r.isItalic&&N.toggleItalic()}),N.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=(0,Mr.useCallback)(()=>{var b;if(((b=n==null?void 0:n.type)==null?void 0:b.name)==="button"){let g=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",g))return!0}if(i&&r){let g=i.getRuleForItem("italic");if(g&&g.action.type==="toggle_off"){let N=e.chain().focus();return g.action.targets.forEach(T=>{T==="bold"&&r.isBold&&N.toggleBold()}),N.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),f=(0,Mr.useCallback)(()=>{var b;if(((b=n==null?void 0:n.type)==null?void 0:b.name)==="button"){let g=!n.attrs.isStrike;if(l("isStrike",g))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),m=(0,Mr.useCallback)(()=>{var b;if(((b=n==null?void 0:n.type)==null?void 0:b.name)==="button"){let g=!n.attrs.isUnderline;if(l("isUnderline",g))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),p=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),y=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),v=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),C=(0,Mr.useCallback)((b,g)=>e.chain().focus().setLink({href:b,target:g?"_blank":""}).run(),[e]),P=(0,Mr.useCallback)(()=>{let b=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:T}=e.state,R=T.$anchor;if(b){let E=R.node();(E.type.name==="paragraph"||E.type.name==="heading")&&o(E)}else for(let E=R.depth;E>0;E--){let w=R.node(E);if(w.type.name==="blockquote"){if(w.attrs.id)o(w);else{let k=R.before(E),x=`node-${(0,a5.v4)()}`,A=e.state.tr;A.setNodeMarkup(k,void 0,{...w.attrs,id:x}),e.view.dispatch(A);let M=e.state.doc.nodeAt(k);M&&o(M)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:f,onUnderline:m,onAlignLeft:p,onAlignCenter:y,onAlignRight:h,onAlignJustify:v,onLink:C,onQuote:P,resetButtonFormatting:c}},"useTextmenuCommands");var Mc=require("react/jsx-runtime"),Yy=a(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return"Drop here"}},"getPlaceholderLabel"),Ac=a(({type:e})=>(0,Mc.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,Mc.jsx)("div",{className:D("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator"),children:(0,Mc.jsx)("div",{className:"courier-text-accent-foreground",children:Yy(e)})})}),"DropIndicatorPlaceholder");var ut=require("react/jsx-runtime");function Xy(){let[e,t]=(0,He.useState)(!1);return(0,He.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(Xy,"useMountStatus");var tr=a(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let s=(0,He.useRef)(null),l=(0,He.useRef)(null),c=(0,He.useRef)(null),[u,d]=(0,He.useState)(!1),[f,m]=(0,He.useState)(null),[p,y]=(0,He.useState)(null),h=(0,He.useRef)(null),v=(0,He.useRef)(!1),C=(0,He.useRef)(null),P=(0,He.useRef)(null),b=(0,He.useRef)(null),g=Xy(),N=u&&!g,T=(0,He.useCallback)(()=>{if(!o||!t)return null;let E=null;return o.state.doc.descendants((w,k,x)=>{var A;if(((A=w.attrs)==null?void 0:A.id)===t){let M=0;return x&&x.content.forEach((S,L,I)=>{S===w&&(M=I)}),E={node:w,pos:k,parent:x,index:M},!1}return!0}),E},[t,o]),R=(0,He.useCallback)(()=>{if(!o)return!1;let E=T();return!E||!E.parent?!1:E.index===E.parent.childCount-1},[o,T]);return(0,He.useEffect)(()=>{let E=s.current,w=l.current;if(!E)return;let k=zo(Qa({element:E,dragHandle:w||void 0,getInitialData:()=>{var L,I,B,F,U,W;let x=T(),A="text";if(x){let O=x.node;switch(O.type.name){case"heading":A="heading";break;case"paragraph":A="text";break;case"imageBlock":A="image";break;case"divider":A=(L=O.attrs)!=null&&L.spacer?"spacer":"divider";break;case"button":A="button";break;case"customCode":A="customCode";break;case"column":A="column";break}}let M=(x==null?void 0:x.parent)===o.state.doc,S=((I=x==null?void 0:x.parent)==null?void 0:I.type.name)==="columnCell";return{id:t,type:M?"editor":S?"column-cell-item":"nested-drag",index:(B=x==null?void 0:x.index)!=null?B:0,dragType:A,pos:x==null?void 0:x.pos,originalIndex:(F=x==null?void 0:x.index)!=null?F:0,columnId:S?(U=x==null?void 0:x.parent)==null?void 0:U.attrs.columnId:void 0,cellIndex:S?(W=x==null?void 0:x.parent)==null?void 0:W.attrs.index:void 0}},onGenerateDragPreview:()=>{let x=E.querySelectorAll("[data-no-drag-preview]"),A=[];x.forEach((M,S)=>{let L=M;A[S]=L.style.display,L.style.display="none"}),requestAnimationFrame(()=>{x.forEach((M,S)=>{let L=M;L.style.display=A[S]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let x=a(A=>{P.current=A.clientY},"handleMouseMove");document.addEventListener("mousemove",x),b.current=()=>{document.removeEventListener("mousemove",x)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",b.current&&(b.current(),b.current=null),o&&o.setEditable(!0)}}),Ur({element:E,getData:({input:x,element:A})=>{var W,O,$,Z;let M=T(),S=(M==null?void 0:M.parent)===o.state.doc,L=((W=M==null?void 0:M.parent)==null?void 0:W.type.name)==="columnCell",I={id:t,type:S?"editor":L?"column-cell-item":"nested-drag",index:(O=M==null?void 0:M.index)!=null?O:0,pos:M==null?void 0:M.pos,nodeType:M==null?void 0:M.node.type.name,columnId:L?($=M==null?void 0:M.parent)==null?void 0:$.attrs.columnId:void 0,cellIndex:L?(Z=M==null?void 0:M.parent)==null?void 0:Z.attrs.index:void 0};if(A.getAttribute("data-node-type")==="column"){let te=A.getBoundingClientRect(),ee=x.clientY,V=30,q=Math.abs(ee-te.top),ce=Math.abs(ee-te.bottom);if(q>V&&ce>V)return{...I,disableDropIndicator:!0}}let F=A.closest('[data-column-cell="true"]');if(R()&&E){let te=E.getBoundingClientRect(),ee=x.clientY,V=te.top+te.height/2;if(ee>=V&&ee>te.bottom)return{...I,[Symbol.for("closestEdge")]:"bottom"}}let U=R()?["top","bottom"]:["top"];return p1(I,{input:x,element:A,allowedEdges:U})},canDrop:({source:x})=>x.data.id!==t,onDragEnter:({self:x,source:A,location:M})=>{var O,$,Z,te,ee;if(x.data.disableDropIndicator){m(null);return}C.current&&(clearTimeout(C.current),C.current=null);let S=M.current.dropTargets;if(S.length>0&&S[0].element!==E){m(null),v.current=!1,h.current=null;return}let L=es(x.data),I=L,B=R(),F=(Z=($=(O=M==null?void 0:M.current)==null?void 0:O.input)==null?void 0:$.clientY)!=null?Z:P.current;F!==null&&(P.current=F);let U=A.data;y(U.dragType||null),L==="bottom"&&B&&A.data.id===t&&(I=null);let W=A.data.type==="editor"||A.data.type==="column-cell-item";if(B&&W)if(L==="top"){let V=s.current;if(V){let q=V.getBoundingClientRect(),ce=(te=F!=null?F:P.current)!=null?te:q.top+q.height/2,fe=q.top+q.height/2,me=q.height,Me=Math.max(10,Math.min(30,me*.3));ce<fe-Me?(v.current=!1,I="top"):v.current?I="bottom":I="top"}else v.current=!1,I="top"}else v.current?I="bottom":L==="bottom"&&(v.current=!0,I="bottom");else B&&!W&&(v.current=!1);if(!v.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let V=A.data.index,q=T();((ee=q==null?void 0:q.index)!=null?ee:0)===V+1&&L==="top"&&(I=null)}I!==h.current&&(h.current=I,m(I))},onDrag:({self:x,source:A,location:M})=>{var O,$,Z,te,ee;if(x.data.disableDropIndicator){m(null);return}C.current&&(clearTimeout(C.current),C.current=null);let S=M.current.dropTargets;if(S.length>0&&S[0].element!==E){m(null);return}let L=(Z=($=(O=M==null?void 0:M.current)==null?void 0:O.input)==null?void 0:$.clientY)!=null?Z:P.current;L!==null&&(P.current=L);let I=es(x.data),B=I,F=R(),U=A.data;y(U.dragType||null),I==="bottom"&&F&&A.data.id===t&&(B=null);let W=A.data.type==="editor"||A.data.type==="column-cell-item";if(F&&W)if(I==="top"){let V=s.current;if(V){let q=V.getBoundingClientRect(),ce=(te=L!=null?L:P.current)!=null?te:q.top+q.height/2,fe=q.top+q.height/2,me=q.height,Me=Math.max(10,Math.min(30,me*.3));ce<fe-Me?(v.current=!1,B="top"):v.current?B="bottom":B="top"}else v.current=!1,B="top"}else v.current?B="bottom":I==="bottom"&&(v.current=!0,B="bottom");else F&&!W&&(v.current=!1);if(!v.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let V=A.data.index,q=T();((ee=q==null?void 0:q.index)!=null?ee:0)===V+1&&I==="top"&&(B=null)}B!==h.current&&(h.current=B,m(B))},onDragLeave:()=>{if(R()&&v.current){let x=E==null?void 0:E.getBoundingClientRect(),A=P.current;if(x&&A!==null&&A>=x.bottom-10)return;C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{v.current=!1,h.current=null,m(null),y(null),C.current=null},150)}else C.current&&(clearTimeout(C.current),C.current=null),v.current=!1,h.current=null,m(null),y(null)},onDrop:()=>{C.current&&(clearTimeout(C.current),C.current=null),v.current=!1,h.current=null,m(null),y(null)}}));return()=>{C.current&&(clearTimeout(C.current),C.current=null),k()}},[t,R,o,T]),(0,ut.jsx)(Qy,{ref:s,id:t,fadeIn:N,className:r,dragging:u,closestEdge:f,dragType:p,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),Qy=(0,He.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:s,id:l,editor:c,fadeIn:u,dragging:d,...f},m)=>{(0,He.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let p=(0,l5.useSetAtom)(ke),{resetButtonFormatting:y}=kc(c),h=a((T,R)=>{let E=null;return T.doc.descendants((w,k)=>{var x;return E!==null?!1:((x=w.attrs)==null?void 0:x.id)===R?(E=k,!1):!0}),E},"findNodePositionById"),v=(0,He.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let T=h(c.state,l);return T===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(T),pos:T}},[c,l]),C=(0,He.useCallback)(()=>{c.commands.blur(),p(null)},[c,p]),P=(0,He.useCallback)(()=>{if(!(!c||!l))try{let{node:T,pos:R}=v();if(!T||R===null)return;let E=T.nodeSize,w=c.state.doc.childCount===1;p(null),c.commands.updateSelectionState(null);let k=c.state.tr;k.delete(R,R+E),k.setMeta("addToHistory",!0),c.view.dispatch(k),w&&setTimeout(()=>{let x=c.state.doc.nodeAt(0);if(x&&x.type.name==="paragraph"&&!x.attrs.id){let A=`node-${(0,c5.v4)()}`,M=c.state.tr;M.setNodeMarkup(0,void 0,{...x.attrs,id:A}),c.view.dispatch(M);let S=new CustomEvent("node-duplicated",{detail:{newNodeId:A}});document.dispatchEvent(S)}},50)}catch(T){console.error("Error deleting node:",T)}},[c,l,v,p]),b=(0,He.useCallback)(()=>{if(!(!c||!l))try{let{node:T,pos:R}=v();if(!T||R===null)return;if(T.type.name==="button"){y();return}let E=T.type.name==="blockquote";E||C(),setTimeout(()=>{let w=c.chain();if(w.setNodeSelection(R).unsetAllMarks(),E&&T.content&&T.content.firstChild?T.content.firstChild.type.name!=="paragraph"&&w.setParagraph():T.type.name!=="paragraph"&&!E&&w.setParagraph(),w.run(),E){let k=v();k.node&&k.pos!==null&&(p(k.node),c.commands.updateSelectionState(k.node))}},100)}catch(T){console.error("Error removing formatting:",T)}},[c,l,v,C,y,p]),g=(0,He.useCallback)(()=>{if(!(!c||!l))try{C(),setTimeout(()=>{let{node:T,pos:R}=v();if(!T||R===null)return;let E=T.type.name,w={...T.attrs};delete w.id;let k=R+(T==null?void 0:T.nodeSize);e5(c,E,k,w,x=>p(x),T.content)},100)}catch(T){console.error("Error duplicating node:",T)}},[c,l,v,C,p]),{node:N}=v();return(0,ut.jsxs)(s5.NodeViewWrapper,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:D("courier-flex courier-flex-col courier-relative draggable-item",t),...f,children:[i==="top"&&(0,ut.jsx)(Ac,{type:s}),(0,ut.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,ut.jsx)(o5,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,ut.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,ut.jsxs)("div",{"data-no-drag-preview":!0,className:D("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center",d&&"!courier-hidden"),children:[(N==null?void 0:N.type.name)!=="imageBlock"&&(N==null?void 0:N.type.name)!=="divider"&&(N==null?void 0:N.type.name)!=="spacer"&&(N==null?void 0:N.type.name)!=="button"&&(N==null?void 0:N.type.name)!=="column"&&(0,ut.jsxs)(ut.Fragment,{children:[(0,ut.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},onClick:T=>{T.stopPropagation(),b()},tabIndex:-1,children:(0,ut.jsx)(vd,{})}),(0,ut.jsx)(be,{className:"courier-m-0"})]}),(0,ut.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},onClick:T=>{T.stopPropagation(),g()},tabIndex:-1,children:(0,ut.jsx)(Qu,{})}),(0,ut.jsx)(be,{className:"courier-m-0"}),(0,ut.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},onClick:T=>{T.stopPropagation(),P()},tabIndex:-1,children:(0,ut.jsx)(Ra,{})})]})]}),i==="bottom"&&(0,ut.jsx)(Ac,{type:s})]})});var wi=require("react/jsx-runtime"),ev=a(({alignment:e,size:t,backgroundColor:r,textColor:o,borderWidth:n,borderRadius:i,borderColor:s,padding:l,fontWeight:c,fontStyle:u,children:d})=>(0,wi.jsx)("div",{className:"courier-w-full node-element",children:(0,wi.jsx)("div",{className:"courier-flex",style:{marginTop:`${l}px`,marginBottom:`${l}px`},children:(0,wi.jsx)("div",{className:D("courier-inline-flex courier-justify-center courier-px-4 courier-py-2 courier-cursor-text courier-text-base",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e],t==="full"&&"courier-w-full"),style:{backgroundColor:r,color:o,borderWidth:`${n}px`,borderRadius:`${i}px`,borderColor:s,borderStyle:n>0?"solid":"none",caretColor:o,fontWeight:c,fontStyle:u},children:d})})}),"ButtonComponent"),p5=a(e=>{let t=(0,d5.useSetAtom)(gt),r=(0,m5.useCallback)(()=>{if(!e.editor.isEditable)return;let o=Rt(e);if(o){let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,wi.jsx)(tr,{id:e.node.attrs.id,className:D(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,wi.jsx)(ev,{...e.node.attrs,children:(0,wi.jsx)(u5.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var g5=require("uuid");var _e={label:"Button",link:"",alignment:"center",size:"default",backgroundColor:"#0085FF",textColor:"#ffffff",borderWidth:0,borderRadius:0,borderColor:"#000000",padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},Sl=Nc.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){It(this.editor,this.name)},addAttributes(){return{label:{default:_e.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:_e.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:_e.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},size:{default:_e.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},backgroundColor:{default:_e.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:_e.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderWidth:{default:_e.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:_e.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:_e.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:_e.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:_e.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:_e.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:_e.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:_e.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,g5.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Nc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,f5.ReactNodeViewRenderer)(p5)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var h5=require("uuid"),Hn=require("jotai"),qt=require("react");var pa=a(({items:e,setItems:t,editor:r})=>{let[o]=(0,qt.useState)(null),[n,i]=(0,qt.useState)(null),[s,l]=(0,qt.useState)(null),[c]=(0,qt.useState)("outer"),u=(0,qt.useRef)([]),d=(0,qt.useRef)([]),f=(0,Hn.useAtomValue)(ze),m=(0,Hn.useSetAtom)(vr),[p,y]=(0,Hn.useAtom)(se),h=(0,Hn.useSetAtom)(lt),v=(0,Hn.useAtomValue)(xn),C=r||f,P=(0,qt.useCallback)(()=>{if(!C)return;let E=C.getJSON(),w=Ce(E),k=St(p,{channel:v,elements:w});y(k),h(k)},[C,v,p,y,h]),b=(0,qt.useCallback)(()=>{C==null||C.commands.removeDragPlaceholder(),t(E=>({...E,Editor:E.Editor.filter(w=>!w.toString().includes("_temp"))}))},[C==null?void 0:C.commands,t]),g=(0,qt.useCallback)(E=>{try{let w=C==null?void 0:C.state.doc;if(!w||E===0)return 0;if(E>=w.childCount)return w.content.size;let k=0;for(let x=0;x<Math.min(E,w.childCount);x++){let A=w.child(x);k+=A.nodeSize}return k}catch(w){return console.error("Error calculating document position:",w),0}},[C==null?void 0:C.state.doc]),N=(0,qt.useCallback)(E=>{let w={};switch(E){case"text":w=Te;break;case"heading":w={};break;case"image":w=Pt;break;case"button":w=_e;break;case"divider":w=Zr;break;case"spacer":w=ql;break;case"customCode":w=nn;break;case"column":w=$t;break}let x={type:E==="text"?"paragraph":E==="image"?"imageBlock":E==="spacer"?"divider":E,attrs:{...w,id:(0,h5.v4)()}};return E==="button"&&(x.content=[{type:"text",text:"Button"}]),x},[]),T=(0,qt.useCallback)((E,w)=>{if(!C)return;let{columnId:k,index:x,isEmpty:A}=w,M=null,S=0,L=-1;if(E.type==="sidebar"){if(!E.dragType)return;M=N(E.dragType)}else if(E.type==="editor"){if(C.state.doc.descendants((W,O)=>W.attrs.id===E.id?(L=O,M=W.toJSON(),S=W.nodeSize,!1):!0),L===-1){let W=e.Editor.findIndex(O=>O===E.id);if(W!==-1){L=g(W);let O=C.state.doc.nodeAt(L);O&&(M=O.toJSON(),S=O.nodeSize)}}if(L!==-1){let W=e.Editor.filter(O=>O!==E.id);W.length!==e.Editor.length&&t({...e,Editor:W})}}if(!M)return;let I=-1,B=null;if(C.state.doc.descendants((W,O)=>W.type.name==="column"&&W.attrs.id===k?(I=O,B=W,!1):!0),I===-1||!B)return;let F=B;L!==-1&&L<I&&(I-=S);let U=C.state.tr;if(L!==-1&&U.delete(L,L+S),A){let W=C.schema,O=Array.from({length:F.attrs.columnsCount},(Z,te)=>W.nodes.columnCell.create({index:te,columnId:k,isEditorMode:!1},te===x?[W.nodeFromJSON(M)]:[])),$=W.nodes.columnRow.create({},O);U.replaceWith(I+1,I+F.nodeSize-1,$)}else{let W=I+1;F.content.forEach(O=>{if(O.type.name==="columnRow"){let $=W+1;O.content.forEach((Z,te,ee)=>{if(ee===x){let V=$+Z.nodeSize-1;U.insert(V,C.schema.nodeFromJSON(M))}$+=Z.nodeSize})}W+=O.nodeSize})}C.view.dispatch(U),P()},[C,e,t,g,N,P]),R=(0,qt.useCallback)((E,w)=>{try{if(E.type==="sidebar"&&(w.type==="editor"||w.type==="column-cell-item"||w.type==="nested-drag")){let k=E.dragType;if(!k||!C)return;let x=w.insertPos;if(x===void 0)if(w.type==="editor"){let S=w.index+1;x=g(S)}else{console.warn("Nested drop without position data");return}let A=N(k);if(C.commands.insertContentAt(x,A),C.state.doc.resolve(x).depth===0){let S=C.state.doc.resolve(x).index(0),L=[...e.Editor];S<=L.length&&(L.splice(S,0,A.attrs.id),t({...e,Editor:L}))}P();return}if((E.type==="editor"||E.type==="column-cell-item"||E.type==="nested-drag")&&(w.type==="editor"||w.type==="column-cell-item"||w.type==="nested-drag")){if(!C)return;let k=-1,x=null;if(E.pos!==void 0&&(k=E.pos,x=C.state.doc.nodeAt(k)),(k===-1||!x)&&C.state.doc.descendants((L,I)=>L.attrs.id===E.id?(k=I,x=L,!1):!0),k===-1||!x){let L=e.Editor.findIndex(I=>I===E.id);L!==-1&&(k=g(L),x=C.state.doc.nodeAt(k))}if(!x||k===-1)return;let A=w.insertPos;if(A===void 0){let L;w.index===void 0?L=C.state.doc.childCount:w.index===-1?L=0:L=w.index+1,A=g(L)}if(A===void 0||A>k&&A<k+x.nodeSize)return;if(A>k){let L=A-x.nodeSize;C.chain().deleteRange({from:k,to:k+x.nodeSize}).insertContentAt(L,x.toJSON()).run()}else C.chain().insertContentAt(A,x.toJSON()).deleteRange({from:k+x.nodeSize,to:k+x.nodeSize*2}).run();let M=e.Editor.includes(E.id);if(M){let L=e.Editor.filter(I=>I!==E.id);t({...e,Editor:L})}let S=C.state.doc.resolve(A).depth===0;P()}}catch(k){console.error("[Pragmatic DnD] Error in handleDrop:",k)}},[e,C,t,g,P,N]);return(0,qt.useEffect)(()=>$d({onDragStart:({source:E})=>{let w=E.data;m(!0),l(w.id),w.dragType&&i(w.dragType);let k=C==null?void 0:C.view.dom.querySelectorAll('[data-node-type="column"]');k&&(u.current=Array.from(k).map(A=>A.getBoundingClientRect()));let x=C==null?void 0:C.view.dom.querySelectorAll("[data-node-view-wrapper]");if(x){let A=new Set,M=Array.from(x).filter(S=>{let L=S,I=L.parentElement;if(I!=null&&I.hasAttribute("data-column-cell"))return!1;let B=L.getBoundingClientRect(),F=B.top+B.height/2;return A.has(Math.round(F))?!1:(A.add(Math.round(F)),!0)});d.current=M.map(S=>S.getBoundingClientRect())}},onDrop:({source:E,location:w})=>{let k=E.data,x=w.current.dropTargets[0];if(!x){b(),m(!1),l(null),i(null);return}let A=x.data;if(A.type==="column-cell"){T(k,A),m(!1),l(null),i(null),b();return}let M=A,S=es(x.data);if(M.pos!==void 0&&S&&C){let L=C.state.doc.nodeAt(M.pos);L&&(S==="top"?M.insertPos=M.pos:S==="bottom"&&(M.insertPos=M.pos+L.nodeSize))}if(M.insertPos===void 0&&S&&M.index!==void 0){let L=S==="top"?M.index-1:M.index;M={...M,index:L}}else if(M.index===void 0&&M.insertPos===void 0){let I=w.current.input.clientY;if(d.current.length>0){let B=0,F=1/0;d.current.forEach((Z,te)=>{let ee=Z.top+Z.height/2,V=Math.abs(I-ee);V<F&&(F=V,B=te)});let U=d.current[B],W=U.top+U.height/2,$=I>=W?B:B-1;M={...M,index:$,fromCoordinates:!0}}else M={...M,index:(C==null?void 0:C.state.doc.childCount)||0}}R(k,M),m(!1),l(null),i(null),b()}}),[C,m,b,l,i,R,T]),{activeId:s,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:b}},"usePragmaticDnd");var Sc=require("react");var b5=require("jotai");var Ic=a(({setItems:e,rafId:t,editor:r})=>{let o=(0,b5.useAtomValue)(ze),n=r||o,i=(0,Sc.useCallback)(s=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=s==null?void 0:s.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(f=>{let m=f,p=m.dataset.id;if(p){let y=m.parentElement,h=!1;for(;y&&y!==c;){if(y.hasAttribute("data-column-cell")){h=!0;break}y=y.parentElement}h||d.push(p)}}),e(f=>({Editor:d,Sidebar:f.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=s==null?void 0:s.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(f=>{let m=f,p=m.dataset.id;if(p){let y=m.parentElement,h=!1;for(;y&&y!==c;){if(y.hasAttribute("data-column-cell")){h=!0;break}y=y.parentElement}h||d.push(p)}}),e(f=>({Editor:d,Sidebar:f.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,Sc.useEffect)(()=>{if(!n||typeof n.on!="function")return;let s,l=a(()=>{n&&(s&&s(),s=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=a(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),s&&s(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var fa=require("react/jsx-runtime"),As=[{type:"text",align:"left",content:`
189
+ `,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],tv=(0,Le.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:s,dataMode:l,hidePreviewPanelExitButton:c,...u},d)=>{let f=(0,Ar.useAtomValue)(ze),[m,p]=(0,Ar.useAtom)(ke),[y,h]=(0,Ar.useAtom)(Zn),v=(0,Le.useRef)({}),[C,P]=(0,Le.useState)(c?"desktop":void 0),b=(0,Ar.useAtomValue)(Tt),g=(0,Ar.useAtomValue)(ge),N=(0,Ar.useAtomValue)(hu),T=(0,Ar.useAtomValue)(Uo),R=(0,Le.useRef)(-1),E=(0,Ar.useSetAtom)(vf),w=(0,Le.useRef)(!1),k=(0,Le.useRef)(!1),[x]=(0,Ar.useAtom)(se),A=(0,Ar.useAtomValue)(bo),M=(0,Ar.useAtomValue)(Ut),[S,L]=(0,Le.useState)({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),I=(0,Le.useRef)(null);pa({items:S,setItems:L,editor:f});let{syncEditorItems:B}=Ic({setItems:L,rafId:I,editor:f});(0,Le.useEffect)(()=>{M&&(k.current=!1)},[M]);let[F,U]=(0,Le.useState)(!1);(0,Le.useEffect)(()=>{if(g===!1||g===null){let V=setTimeout(()=>{U(!0)},100);return()=>clearTimeout(V)}else U(!1)},[g,F]),(0,Le.useEffect)(()=>{if(m){let V=m.type.name,q=al(V);E({nodeName:V,config:q})}},[m,E]);let W=(0,Le.useMemo)(()=>{var q,ce,fe,me,Me,mt,de,Ie,Pe,nt,it,Yt,Xt,at,pt,br,Qt,ie,yr,Kr,Yr,Ho,Un,zn,_n,$n,jn,H,J,ne,Ee,he,st,Nt;if(T)return T;let V=(fe=(ce=(q=b==null?void 0:b.data)==null?void 0:q.tenant)==null?void 0:ce.brand)==null?void 0:fe.settings;return{brandColor:((me=V==null?void 0:V.colors)==null?void 0:me.primary)||"#000000",textColor:((Me=V==null?void 0:V.colors)==null?void 0:Me.secondary)||"#000000",subtleColor:((mt=V==null?void 0:V.colors)==null?void 0:mt.tertiary)||"#666666",headerStyle:(Ie=(de=V==null?void 0:V.email)==null?void 0:de.header)!=null&&Ie.barColor?"border":"plain",logo:(it=(nt=(Pe=V==null?void 0:V.email)==null?void 0:Pe.header)==null?void 0:nt.logo)==null?void 0:it.image,link:(at=(Xt=(Yt=V==null?void 0:V.email)==null?void 0:Yt.header)==null?void 0:Xt.logo)==null?void 0:at.href,facebookLink:(ie=(Qt=(br=(pt=V==null?void 0:V.email)==null?void 0:pt.footer)==null?void 0:br.social)==null?void 0:Qt.facebook)==null?void 0:ie.url,linkedinLink:(Ho=(Yr=(Kr=(yr=V==null?void 0:V.email)==null?void 0:yr.footer)==null?void 0:Kr.social)==null?void 0:Yr.linkedin)==null?void 0:Ho.url,instagramLink:($n=(_n=(zn=(Un=V==null?void 0:V.email)==null?void 0:Un.footer)==null?void 0:zn.social)==null?void 0:_n.instagram)==null?void 0:$n.url,mediumLink:(ne=(J=(H=(jn=V==null?void 0:V.email)==null?void 0:jn.footer)==null?void 0:H.social)==null?void 0:J.medium)==null?void 0:ne.url,xLink:(Nt=(st=(he=(Ee=V==null?void 0:V.email)==null?void 0:Ee.footer)==null?void 0:he.social)==null?void 0:st.twitter)==null?void 0:Nt.url}},[T,b]),O=N&&!!W,$=(0,Le.useCallback)(()=>{Object.values(v.current).forEach(V=>clearTimeout(V)),v.current={}},[]);(0,Le.useEffect)(()=>()=>{$()},[$]),(0,Le.useEffect)(()=>{let V=a(q=>{if(q.key==="Escape"&&(p(null),f==null||f.commands.blur(),R.current=-1),q.key==="Tab"&&f){q.preventDefault();let ce=-1;m&&f.state.doc.content.forEach((Me,mt,de)=>{m.attrs.id===Me.attrs.id&&(ce=de)}),ce===-1&&(ce=0);let fe=f.state.doc,me;if(q.shiftKey?me=(ce-1+fe.childCount)%fe.childCount:me=(ce+1)%fe.childCount,me!==ce||m===null){let Me=fe.child(me);p(Me),f.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",V),()=>{document.removeEventListener("keydown",V)}},[f,m,p]),(0,Le.useEffect)(()=>{if(g!==!1||M)return;let V=x!=null?x:"";if(V){let q=Mu(V,"email");h(q||"")}setTimeout(()=>{if(!(!f||f.isDestroyed)&&f.state.doc.childCount===1){let q=f.state.doc.child(0);p(q)}},0)},[b,g,M,f,h,p,x]),(0,Le.useEffect)(()=>{g===!1&&b&&!k.current&&(k.current=!0,setTimeout(()=>{f&&!f.isDestroyed&&B(f)},300))},[g,b,f,B]),(0,Le.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let Z=(0,Le.useCallback)(V=>{let ce=V||(C===void 0?"desktop":void 0);P(ce),p(null),ce?f==null||f.setEditable(!1):f==null||f.setEditable(!0)},[f,C,P,p]),te=a(V=>{h(V.target.value)},"handleSubjectChange"),ee=(0,Le.useMemo)(()=>{if(g!==!1||!F)return null;let V=s&&s.elements&&s.elements.length>0;V&&(k.current=!0);let q;return V&&(q=s.elements.find(fe=>fe.type==="channel"&&fe.channel==="email")),q||(q={type:"channel",channel:"email",elements:As}),Qe({version:"2022-01-01",elements:[q]},{channel:"email"})},[s,g,F]);return M&&(x===null||ee===null)?null:(0,fa.jsx)(wr,{theme:t,dataMode:l,isLoading:!!g,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,fa.jsx)(no,{hidePublish:e,channels:r,routing:o}),...u,children:(0,fa.jsx)(fa.Fragment,{children:n==null?void 0:n({subject:y,handleSubjectChange:te,selectedNode:m,setSelectedNode:p,previewMode:C,templateEditor:f,ref:d,isBrandApply:O,brandSettings:W,items:S,content:ee,syncEditorItems:B,brandEditorContent:A,templateData:b,togglePreviewMode:Z,hidePreviewPanelExitButton:c})})})}),Lc=(0,Le.memo)(tv);var Rc=class Rc{};a(Rc,"UploadImageAPI"),Rc.uploadImage=a(async t=>new Promise((r,o)=>{let n=new FileReader;n.onload=()=>{typeof n.result=="string"?r(n.result):o(new Error("Failed to convert image to data URL"))},n.onerror=()=>{o(new Error("Failed to read image file"))},n.readAsDataURL(t)}),"uploadImage");var _m=Rc,$m=_m;var Nr=a(e=>[tm,Um.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1}),lm.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Hm.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),Pg,em,sm,Zd,om.configure({levels:[1,2,3,4,5,6]}),Sl,Dl,Bm.Color,Fl,Ol,_l,jl,im.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Wm.Underline,ic.configure(),Gl.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await $m.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await $m.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Vm.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Om.Typography,Fm.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),jd.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Lm.configure({variables:e==null?void 0:e.variables,disableSuggestions:e==null?void 0:e.disableVariableAutocomplete}),Im,Rm,Dm,Yl,ec],"ExtensionKit");var Oc=require("@tiptap/react");var y5=require("jotai"),Ei=require("react");var Dc=a(e=>{let t=(0,y5.useAtomValue)(ke),[r,o]=(0,Ei.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Ei.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,Ei.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,Ei.useCallback)(({editor:s})=>{let l=["paragraph","heading","blockquote"],{$head:c,$anchor:u}=s.state.selection,d=c.node();if(l.includes(d.type.name)&&d.attrs.isSelected)return!0;for(let f=1;f<=c.depth;f++){let m=c.node(f);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let p=s.isFocused&&(c.pos!==u.pos||s.state.selection.from!==s.state.selection.to),y=s.isFocused;return p||y}}return!1},[]),...r}},"useTextmenuStates");var Fc=require("jotai"),ot=require("lucide-react"),Ir=require("react");var Bc=require("react");var C5=Ae(require("@tippyjs/react"),1),x5=require("react");var mr=require("react/jsx-runtime"),v5=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,rv=a(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-neutral-500 courier-border-b-2";return e==="Mod"?(0,mr.jsx)("kbd",{className:t,children:v5?"\u2318":"Ctrl"}):e==="Shift"?(0,mr.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,mr.jsx)("kbd",{className:t,children:v5?"\u2325":"Alt"}):(0,mr.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),T5=a(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=(0,x5.useCallback)(s=>(0,mr.jsxs)("span",{className:"courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-white courier-border courier-border-neutral-100 courier-rounded-lg courier-shadow-sm courier-z-[999]",tabIndex:-1,"data-placement":s["data-placement"],"data-reference-hidden":s["data-reference-hidden"],"data-escaped":s["data-escaped"],children:[r&&(0,mr.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-neutral-500",children:r}),o&&(0,mr.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(l=>(0,mr.jsx)(rv,{children:l},l))})]}),[o,r]);return t?(0,mr.jsx)(C5.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:i,animation:!1,children:(0,mr.jsx)("span",{children:e})}):(0,mr.jsx)(mr.Fragment,{children:e})},"Tooltip");var Ns=require("react/jsx-runtime"),w5=(0,Bc.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let s=D("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Ns.jsx)(Sm,{className:s,...n,ref:i,children:t})});w5.displayName="Toolbar";var E5=(0,Bc.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=D("courier-bg-neutral-200 dark:courier-bg-neutral-800",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Ns.jsx)("div",{className:n,ref:o,...r})});E5.displayName="Toolbar.Divider";var P5=(0,Bc.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...s},l)=>{let c=D("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=(0,Ns.jsx)(Ve,{className:c,variant:r,buttonSize:t,ref:l,...s,children:e});return n?(0,Ns.jsx)(T5,{title:n,shortcut:i,children:u}):u});P5.displayName="ToolbarButton";var Hc={Wrapper:w5,Divider:E5,Button:P5};var k5=require("lucide-react"),M5=require("react");var Sr=require("react/jsx-runtime"),ov=a(e=>e.type==="option","isOption"),A5=a(({options:e,containerRef:t})=>{let r=(0,M5.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,Sr.jsxs)(qs,{children:[(0,Sr.jsx)(Js,{asChild:!0,children:(0,Sr.jsxs)(Ve,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,Sr.jsx)(k5.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,Sr.jsx)(Aa,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(ov(o))return(0,Sr.jsx)(Na,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,Sr.jsx)(Sr.Fragment,{children:o.id==="heading1"?(0,Sr.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,Sr.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,Sr.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var N5=require("@tiptap/react");var S5=a(e=>(0,N5.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var At=require("react/jsx-runtime"),nv=(0,Ir.memo)(Hc.Button),iv=(0,Ir.memo)(A5),Vc=a(({editor:e,config:t})=>{var R;let r=Dc(e),o=S5(e),n=(0,Ir.useRef)(null),i=(0,Fc.useAtomValue)(sl),s=(0,Fc.useAtomValue)(ke),l=s==null?void 0:s.type.name,c=(0,Fc.useAtomValue)(yf),[u,d]=(0,Ir.useState)(()=>{let{selection:E}=e.state;return{from:E.from,to:E.to,empty:E.empty}});(0,Ir.useEffect)(()=>{let E=a(()=>{let{selection:w}=e.state;d({from:w.from,to:w.to,empty:w.empty})},"updateSelection");return e.on("selectionUpdate",E),e.on("transaction",E),()=>{e.off("selectionUpdate",E),e.off("transaction",E)}},[e]);let f=(0,Ir.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),m=(0,Ir.useMemo)(()=>t||c(l||"",f),[t,c,l,f]),p=kc(e,m,r),y=a(()=>{let{selection:E}=e.state;if(!(E.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let w=e.state.tr.setMeta("showLinkForm",{from:E.from,to:E.to});e.view.dispatch(w)}else{let w=e.state.tr.setMeta("showLinkForm",{from:E.from,to:E.to});e.view.dispatch(w)}},"handleLinkToggle"),h=a(()=>{if(i.ref){let A=i.ref,M=A.value,S=i.caretPosition||A.selectionStart||0,L=M.substring(0,S),I=M.substring(S),B=`${L}{{${I}`,F=S+2;A.focus();let U=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(U,"target",{writable:!1,value:{...A,value:B}}),A.value=B,A.dispatchEvent(U),A.setSelectionRange(F,F),A.getBoundingClientRect()){let O=B.slice(0,F),$=document.createElement("span");$.style.font=window.getComputedStyle(A).font,$.style.whiteSpace="pre-wrap",$.textContent=O,document.body.appendChild($);let Z=$.offsetWidth;document.body.removeChild($);let te=parseInt(window.getComputedStyle(A).lineHeight),ee=O.split(`
190
+ `).length-1,V=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(Z%A.offsetWidth,A.offsetWidth-200),top:ee*te+30}},bubbles:!0});A.dispatchEvent(V)}return}let{state:E,dispatch:w}=e.view,{tr:k}=E;k.insertText("{{"),w(k),e.commands.focus();let x=e.state.tr.setMeta("showVariableSuggestions",{from:e.state.selection.from,to:e.state.selection.to});e.view.dispatch(x)},"handleVariableClick"),v=a((E,w,k,x,A,M,S)=>{let L=m[E];return!L||Array.isArray(L)||L.state==="hidden"?null:(0,At.jsx)(nv,{tooltip:k,tooltipShortcut:M,onClick:x,active:A,disabled:L.state==="disabled",...S,children:w},E)},"renderButton"),C=a((E,w)=>{let k=E.filter(x=>!!x);return k.length>0?(0,At.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:k},w):null},"renderGroup"),P=C([((R=m.contentType)==null?void 0:R.state)==="enabled"&&(0,At.jsx)(iv,{options:o,containerRef:n},"content-type")],"content-type-group"),b=C([v("bold",(0,At.jsx)(ot.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",p.onBold,r.isBold,["Mod","B"]),v("italic",(0,At.jsx)(ot.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",p.onItalic,r.isItalic,["Mod","I"]),v("underline",(0,At.jsx)(ot.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",p.onUnderline,r.isUnderline,["Mod","U"]),v("strike",(0,At.jsx)(ot.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",p.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),g=C([v("alignLeft",(0,At.jsx)(ot.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",p.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),v("alignCenter",(0,At.jsx)(ot.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",p.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),v("alignRight",(0,At.jsx)(ot.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",p.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),v("alignJustify",(0,At.jsx)(ot.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",p.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),N=C([v("quote",(0,At.jsx)(ot.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",p.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),T=C([v("link",(0,At.jsx)(ot.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",y,r.isLink,["Mod","K"]),v("variable",(0,At.jsx)(ot.Braces,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,At.jsx)(Hc.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[P,b,g,N,T].filter(Boolean).map((E,w)=>(0,At.jsxs)(Ir.Fragment,{children:[E,w<[P,b,g,N,T].filter(Boolean).length-1&&(0,At.jsx)(Hc.Divider,{})]},`item-${w}`))})},"TextMenu");var jm=require("react/jsx-runtime"),Lr=a(({config:e})=>{let{editor:t}=(0,Oc.useCurrentEditor)(),r=Dc(t);return t?(0,jm.jsx)(Oc.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var s,l,c,u;let o=(c=(l=(s=t==null?void 0:t.state)==null?void 0:s.selection)==null?void 0:l.from)!=null?c:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,jm.jsx)(Vc,{editor:t,config:e})}):null},"BubbleTextMenu");var I5=require("@tiptap/pm/state"),ga=require("@tiptap/react"),Ss=require("jotai"),io=require("react");var Jt=require("react/jsx-runtime"),av=a(({value:e,readOnly:t})=>{let{editor:r}=(0,ga.useCurrentEditor)(),o=(0,Ss.useSetAtom)(Li),n=(0,Ss.useAtomValue)(ge),i=(0,io.useRef)(!1);return(0,io.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Pu(e!=null?e:"")))},[r,e,n,t]),(0,io.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),sv=a(({variables:e,facebookLink:t,linkedinLink:r,instagramLink:o,mediumLink:n,xLink:i,readOnly:s=!1,value:l,onUpdate:c})=>{let d=(0,io.useRef)(!1),f=(0,Ss.useSetAtom)(ke),m=(0,io.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...e}),[e]),p=ga.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:h})=>{let{state:v,dispatch:C}=h.view;return C(v.tr.setSelection(I5.TextSelection.create(v.doc,v.selection.$anchor.pos))),f&&f(null),!1}}}});(0,io.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let y=(0,io.useMemo)(()=>[...Nr({variables:m,setSelectedNode:f,disableVariableAutocomplete:!0}),p].filter(h=>h!==void 0),[p,m,f,!0]);return(0,Jt.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,Jt.jsxs)(ga.EditorProvider,{content:Pu(l!=null?l:""),extensions:y,editable:!s,autofocus:!s,onUpdate:c,editorContainerProps:{className:D("courier-py-2 courier-flex-grow",s&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,Jt.jsx)(av,{value:l,readOnly:s}),(0,Jt.jsx)(Lr,{})]}),(0,Jt.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[t&&(0,Jt.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(Ha,{className:"courier-w-5 courier-h-5"})}),r&&(0,Jt.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(Oa,{className:"courier-w-5 courier-h-5"})}),o&&(0,Jt.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(Va,{className:"courier-w-5 courier-h-5"})}),n&&(0,Jt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(Wa,{className:"courier-w-5 courier-h-5"})}),i&&(0,Jt.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:(0,Jt.jsx)(ja,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),ha=(0,io.memo)(sv);var Rr=require("react/jsx-runtime"),L5=a(({value:e,icon:t,...r})=>(0,Rr.jsx)(tt,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),Wc=a(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,Rr.jsxs)("div",{...n,className:D("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",n.className),children:[e&&!r&&(0,Rr.jsxs)(Rr.Fragment,{children:[(0,Rr.jsxs)(er,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,Rr.jsx)(L5,{value:"desktop",icon:(0,Rr.jsx)(Yu,{})}),(0,Rr.jsx)(L5,{value:"mobile",icon:(0,Rr.jsx)(md,{})})]}),!o&&(0,Rr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,Rr.jsxs)(Ve,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var qm=require("react");function lv(){typeof window!="undefined"&&(window.__COURIER_CREATE_TEST__||(window.__COURIER_CREATE_TEST__={editors:{email:null,sms:null,push:null,inbox:null,slack:null,teams:null},currentEditor:null,activeChannel:null,templateEditorContent:null}))}a(lv,"initTestHelpers");function Dr(e,t){typeof window!="undefined"&&(lv(),window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.editors[e]=t,window.__COURIER_CREATE_TEST__.currentEditor=t,window.__COURIER_CREATE_TEST__.activeChannel=t?e:null))}a(Dr,"setTestEditor");var B5=require("@tiptap/core"),H5=require("@tiptap/pm/state"),Uc=require("@tiptap/react"),dt=require("jotai"),we=require("react");var R5=require("@tiptap/react"),D5=require("react");var ao=a(({value:e,defaultValue:t})=>{let{editor:r}=(0,R5.useCurrentEditor)();return(0,D5.useEffect)(()=>{r&&r.commands.setContent(e||t)},[r,e,t]),null},"ReadOnlyEditorContent");var qo=require("react/jsx-runtime"),cv=a(({value:e})=>{let{editor:t}=(0,Uc.useCurrentEditor)(),[r,o]=(0,dt.useAtom)(se),n=(0,dt.useSetAtom)(lt),i=(0,dt.useAtomValue)(Zn),s=(0,dt.useAtomValue)(ke),l=(0,dt.useSetAtom)(ze),c=(0,dt.useSetAtom)(Jn),u=(0,we.useRef)(!1),d=(0,we.useRef)(),f=(0,dt.useAtomValue)(ge),m=(0,dt.useAtomValue)(Tt),p=(0,we.useRef)(!1),y=(0,dt.useAtomValue)(Ut);return(0,we.useEffect)(()=>{f&&(p.current=!1)},[f]),(0,we.useEffect)(()=>(c({action:"register",id:"email-subject",fn:a(()=>{var v;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&f===!1&&!y))try{let C=Ce(t.getJSON());if(!C||!Array.isArray(C))return;let P=i;if(!i&&r){let T=(v=r==null?void 0:r.elements)==null?void 0:v.find(R=>R.type==="channel"&&R.channel==="email");T&&(P=Ma(T,"email"))}let b=po(r,"email",P||"",C),g={elements:b.elements,channel:"email",...b.raw&&{raw:b.raw}},N=St(r,g);JSON.stringify(r)!==JSON.stringify(N)&&(o(N),n(N))}catch(C){console.error("[FlushSubjectUpdate]",C)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,f,y,r,o,n,c]),(0,we.useEffect)(()=>{!t||f!==!1||p.current||!e||(l(t),p.current=!0,t.commands.setContent(e))},[t,e,l,f]),(0,we.useEffect)(()=>{if(!(!(t&&i!==null)||f!==!1||y)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let v=Ce(t.getJSON());if(!v||!Array.isArray(v))return;let C=i;if(!i&&r){let N=(h=r==null?void 0:r.elements)==null?void 0:h.find(T=>T.type==="channel"&&T.channel==="email");N&&(C=Ma(N,"email"))}let P=po(r,"email",C||"",v),b={elements:P.elements,channel:"email",...P.raw&&{raw:P.raw}},g=St(r,b);JSON.stringify(r)!==JSON.stringify(g)&&(o(g),n(g))}catch(v){console.error(v)}},500),()=>{d.current&&clearTimeout(d.current)}},[m,t,i,o,n,f,r,y]),(0,we.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,we.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(s)},[t,s]),(0,we.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),uv=a(({value:e,readOnly:t=!1,variables:r,onDestroy:o,onUpdate:n,subject:i})=>{let l=(0,dt.useSetAtom)(ll),c=(0,we.useRef)(),[u,d]=(0,dt.useAtom)(se),f=(0,dt.useAtomValue)(Zn),m=i!=null?i:f,p=(0,dt.useSetAtom)(ke),y=(0,dt.useAtomValue)(ze),h=(0,dt.useAtomValue)(Ut),v=(0,dt.useAtomValue)(vr),C=(0,dt.useSetAtom)(Jn),P=(0,dt.useSetAtom)(lt),b=(0,we.useRef)(u),g=(0,we.useRef)(m),N=(0,we.useRef)(v);(0,we.useEffect)(()=>{b.current=u},[u]),(0,we.useEffect)(()=>{g.current=m},[m]),(0,we.useEffect)(()=>{N.current=v},[v]),(0,we.useEffect)(()=>{y==null||y.setEditable(!t)},[t,y]);let T=B5.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:O})=>{let{state:$,dispatch:Z}=O.view;return Z($.tr.setSelection(H5.TextSelection.create($.doc,$.selection.$anchor.pos))),p&&p(null),!1}}}}),R=(0,we.useCallback)(({editor:O})=>{n==null||n(O),Dr("email",O),p&&setTimeout(()=>{p(null)},100)},[p,n]),E=(0,we.useRef)(),w=(0,we.useRef)(null),k=(0,we.useCallback)((O,$)=>{var fe;if(h)return;let Z=b.current,te=g.current;if(!Z){let me={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:$}]};d(me),P(me);return}let ee=Z.elements.find(me=>me.type==="channel"&&me.channel==="email"),V={...ee};V.elements=(fe=V.elements)==null?void 0:fe.filter(me=>me.type!=="meta");let q={type:"channel",channel:"email",elements:$};if(JSON.stringify(V)!==JSON.stringify(q)){let me=te;!te&&ee&&(me=Ma(ee,"email"));let Me=po(Z,"email",me||"",$);q.elements=Me.elements,Me.raw&&(q.raw=Me.raw);let mt=St(Z,q);d(mt),P(mt)}n==null||n(O),Dr("email",O)},[d,P,n,h]),x=(0,we.useCallback)(({editor:O})=>{let $=Ce(O.getJSON());w.current={editor:O,elemental:$},E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{if(w.current){let{editor:Z,elemental:te}=w.current;k(Z,te),w.current=null}},200)},[k]),A=(0,we.useCallback)(({editor:O})=>{if(N.current)return;let{selection:$}=O.state,{$anchor:Z}=$,ee=$.$head.marks().find(fe=>fe.type.name==="link");ee||O.isActive("link")?l({mark:ee}):l(null);let V=Z.depth,q=null,ce=null;for(;V>0;){let fe=Z.node(V);!ce&&fe.type.name==="blockquote"&&(ce=fe),!q&&(fe.type.name==="paragraph"||fe.type.name==="heading")&&(q=fe),V--}ce?p(ce):q&&p(q)},[l,p]),M=(0,we.useCallback)(({editor:O,transaction:$})=>{let Z=$==null?void 0:$.getMeta("showLinkForm");if(Z){let{selection:te}=O.state,V=te.$head.marks().find(q=>q.type.name==="link");l({mark:V,link:{from:Z.from,to:Z.to}})}},[l]),S=(0,we.useCallback)(()=>{c.current&&clearTimeout(c.current),E.current&&clearTimeout(E.current),o==null||o(),Dr("email",null)},[o]);(0,we.useEffect)(()=>(C({action:"register",id:"email-content",fn:a(()=>{if(E.current&&(clearTimeout(E.current),E.current=void 0,w.current)){let{editor:$,elemental:Z}=w.current;k($,Z),w.current=null}},"flushContentUpdate")}),()=>{C({action:"unregister",id:"email-content"})}),[k,C]);let L=(0,we.useCallback)(O=>{var V;if(N.current)return;let $=(V=O.view)==null?void 0:V.editor;if(!$||!$.isEditable)return;let Z=O.target,te=$.view.posAtDOM(Z,0),ee=$.state.doc.resolve(te).node();ee.type.name==="paragraph"&&p(ee)},[p]),I=(0,we.useCallback)(()=>!N.current,[]),B=(0,we.useMemo)(()=>[...Nr({variables:r,setSelectedNode:p,shouldHandleClick:I,disableVariableAutocomplete:!0}),T].filter(O=>O!==void 0),[T,r,p,I,!0]),F=e||{type:"doc",content:[{type:"paragraph"}]},U=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:R,onUpdate:x,onSelectionUpdate:A,onTransaction:M},W=(0,we.useRef)(null);return(0,we.useEffect)(()=>{let O=W.current;if(!(!O||t))return Ur({element:O,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:$})=>$.data.type==="sidebar"?!0:$.data.type==="editor"})},[t]),(0,qo.jsx)("div",{ref:W,children:(0,qo.jsx)(Uc.EditorProvider,{content:F,extensions:B,...U,onDestroy:S,editorContainerProps:{onClick:L},"data-testid":"editor-provider",immediatelyRender:!1,children:t?(0,qo.jsx)(ao,{value:F,defaultValue:As}):(0,qo.jsxs)(qo.Fragment,{children:[(0,qo.jsx)(cv,{value:F}),(0,qo.jsx)(Lr,{})]})})})},"EmailEditor"),zc=uv;var Is=require("jotai"),F5=require("lucide-react");var Fn=require("react");var _c=require("react/jsx-runtime"),ba=a(({children:e,id:t,className:r,editor:o})=>(0,_c.jsx)(dv,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),dv=(0,Fn.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,Fn.useRef)(null),[s,l]=(0,Fn.useState)(!1);return(0,Fn.useEffect)(()=>{let c=i.current;if(!(!c||!r))return zo(Qa({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,_c.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:D(t,"courier-relative",s&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,_c.jsx)("div",{children:e})})});var Re=require("react/jsx-runtime"),$c=a(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=(0,Is.useAtomValue)(Tt),i=(0,Is.useSetAtom)(Ji),s=(0,Is.useAtomValue)(Ot);return(0,Re.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Re.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)("p",{children:r}),(0,Re.jsx)(be,{className:"courier-my-4"})]}),(0,Re.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>(0,Re.jsx)(ba,{id:u.toString(),editor:o,children:(0,Re.jsxs)("div",{className:D("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Re.jsx)(F5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),u==="heading"&&(0,Re.jsx)(Tl,{draggable:!0}),u==="text"&&(0,Re.jsx)(An,{draggable:!0}),u==="image"&&(0,Re.jsx)(wl,{draggable:!0}),u==="spacer"&&(0,Re.jsx)(El,{draggable:!0}),u==="divider"&&(0,Re.jsx)(Mn,{draggable:!0}),u==="button"&&(0,Re.jsx)(kn,{draggable:!0}),u==="customCode"&&(0,Re.jsx)(as,{draggable:!0}),u==="column"&&(0,Re.jsx)(xl,{draggable:!0})]})},u))})]}),t&&(0,Re.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Re.jsx)(be,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?(0,Re.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Re.jsx)(Ve,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!s,children:"Edit brand"})}):(0,Re.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Re.jsx)("h3",{className:"courier-text-md courier-font-medium",children:"Customize brand theme"}),(0,Re.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Re.jsx)(Ve,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var V5=require("jotai");var Ao=require("react/jsx-runtime"),jc=a(({element:e,editor:t})=>{var i,s;let r=(0,V5.useAtomValue)(Id);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((s=e.marks)!=null&&s.some(l=>l.type.name==="link")))return(0,Ao.jsx)(Yg,{editor:t,mark:r==null?void 0:r.mark,pendingLink:r==null?void 0:r.link});let o=t==null?void 0:t.isActive("blockquote"),n=a(()=>{if(!t)return;let{$anchor:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Ao.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Ao.jsx)(B1,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Ao.jsx)(yg,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Ao.jsx)(Hg,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Ao.jsx)(Zg,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Ao.jsx)(Qd,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Ao.jsx)(S1,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Ao.jsx)(Kd,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var Zm=require("react"),O5=require("jotai");var dn=require("react/jsx-runtime"),Vn=(0,Zm.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,dn.jsx)("div",{className:D("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),On=(0,Zm.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},s)=>{let[l,c]=(0,O5.useAtom)(Vo),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,dn.jsxs)(dn.Fragment,{children:[u&&(0,dn.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),(0,dn.jsx)("div",{className:D("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,dn.jsx)("div",{className:D("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto courier-bg-white","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":d+" courier-translate-x-0"),...i,ref:s,children:e})})]})});var Ls=require("jotai");var Ke=require("react/jsx-runtime"),Jm=(0,qm.forwardRef)(({children:e,className:t,...r},o)=>(0,Ke.jsx)("div",{className:D("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Gm=(0,qm.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,Ke.jsx)("div",{className:D("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),W5=a(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:s,dataMode:l,...c})=>{let u=(0,Ls.useAtomValue)(se),d=(0,Ls.useAtomValue)(Vo),f=(0,Ls.useSetAtom)(Vo),m=a(()=>{d&&f(!1)},"handleSubjectAreaClick");return(0,Ke.jsx)(Lc,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:s,dataMode:l,render:({subject:p,handleSubjectChange:y,selectedNode:h,setSelectedNode:v,previewMode:C,templateEditor:P,ref:b,isBrandApply:g,brandSettings:N,items:T,content:R,syncEditorItems:E,brandEditorContent:w,templateData:k,togglePreviewMode:x,hidePreviewPanelExitButton:A})=>{var M,S,L,I,B,F;return(0,Ke.jsxs)(Vn,{previewMode:C,children:[(0,Ke.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,Ke.jsxs)("div",{className:"courier-bg-primary courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:m,children:[(0,Ke.jsx)("h4",{className:"courier-text-sm",children:"Subject: "}),(0,Ke.jsx)(ye,{value:p!=null?p:"",onChange:y,onFocus:()=>v(null),className:"!courier-bg-background read-only:courier-cursor-default read-only:courier-border-transparent md:courier-text-md courier-py-1 courier-border-transparent !courier-border-none courier-font-medium",placeholder:"Write subject...",readOnly:C!==void 0})]}),(0,Ke.jsxs)(Jm,{ref:b,children:[(0,Ke.jsxs)(Gm,{previewMode:C,children:[g&&(0,Ke.jsxs)("div",{className:D("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(N==null?void 0:N.headerStyle)==="border"&&"courier-pt-6"),children:[(N==null?void 0:N.headerStyle)==="border"&&(0,Ke.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:N==null?void 0:N.brandColor}}),(N==null?void 0:N.logo)&&(0,Ke.jsx)("img",{src:N.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),R&&(0,Ke.jsx)(zc,{value:R,onUpdate:E,variables:e}),g&&k&&(0,Ke.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,Ke.jsx)(ha,{readOnly:!0,value:w!=null?w:(F=(B=(I=(L=(S=(M=k==null?void 0:k.data)==null?void 0:M.tenant)==null?void 0:S.brand)==null?void 0:L.settings)==null?void 0:I.email)==null?void 0:B.footer)==null?void 0:F.markdown,variables:e,facebookLink:N==null?void 0:N.facebookLink,linkedinLink:N==null?void 0:N.linkedinLink,instagramLink:N==null?void 0:N.instagramLink,mediumLink:N==null?void 0:N.mediumLink,xLink:N==null?void 0:N.xLink})})]}),(0,Ke.jsx)(Wc,{previewMode:C,togglePreviewMode:x,hideExitButton:A})]})]}),(0,Ke.jsx)(On,{previewMode:C,children:(0,Ke.jsx)("div",{className:"courier-p-1 courier-h-full",children:h?(0,Ke.jsx)(jc,{element:h,editor:P}):(0,Ke.jsx)($c,{items:T.Sidebar,brandEditor:i,label:"Blocks library",editor:P!=null?P:void 0})})})]})},...c})},"EmailLayout");var U5=require("@tiptap/react"),No=require("jotai"),vt=require("react");var Km=require("react/jsx-runtime"),Rs=[{type:"text",content:`
191
191
  `,text_style:"h2"},{type:"text",content:`
192
- `},{type:"action",content:"Register",align:"left",href:""}],X5=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="inbox");if(!t)t={type:"channel",channel:"inbox",elements:Vs};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(m=>m.type==="meta"),n=r.filter(m=>m.type!=="meta"),i=n.filter(m=>m.type==="text"),s=n.filter(m=>m.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
192
+ `},{type:"action",content:"Register",align:"left",href:""}],z5=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="inbox");if(!t)t={type:"channel",channel:"inbox",elements:Rs};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(m=>m.type==="meta"),n=r.filter(m=>m.type!=="meta"),i=n.filter(m=>m.type==="text"),s=n.filter(m=>m.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
193
193
  `,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
194
- `};t={...t,elements:[c,d,...s]}}return t},"getOrCreateInboxElement"),Q5={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},eb=a(({value:e})=>{let{editor:t}=(0,Y5.useCurrentEditor)(),r=(0,So.useSetAtom)(_e),o=(0,So.useAtomValue)(se),n=(0,So.useAtomValue)(be),i=(0,vt.useRef)(!1);return(0,vt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,vt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,vt.useEffect)(()=>{t&&(r(t),Hr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,vt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=X5(o),l=Qe({version:"2022-01-01",elements:[s]},{channel:"inbox"}),c=Te(l),u=Te(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),xv=(0,vt.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,So.useAtomValue)(be),p=(0,vt.useRef)(!0),v=(0,vt.useRef)(!1),h=(0,So.useSetAtom)(Me),[g,C]=(0,So.useAtom)(se),P=(0,So.useSetAtom)(wt),y=(0,So.useAtomValue)(Ut),b=(0,vt.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,vt.useEffect)(()=>(v.current=!0,()=>{v.current=!1}),[]);let A=(0,vt.useMemo)(()=>[...Sr({variables:b,setSelectedNode:h,disableVariableAutocomplete:!0})].filter(T=>T!==void 0),[b,h,!0]),x=(0,vt.useCallback)(({editor:T})=>{if(!T||y)return;if(!g){let D=Te(T.getJSON()),L=bo(null,"inbox","",D),B={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:L.elements,...L.raw&&{raw:L.raw}}]};C(B),P(B);return}let k=T.getJSON(),w=Te(k),E=bo(g,"inbox","",w),N=At(g,{elements:E.elements,channel:"inbox",...E.raw&&{raw:E.raw}}),M=JSON.stringify(g.elements),S=JSON.stringify(N.elements);M!==S&&setTimeout(()=>{v.current&&(C(N),P(N))},100)},[g,C,P,y]),I=(0,vt.useMemo)(()=>{let T=X5(c);return Qe({version:"2022-01-01",elements:[T]},{channel:"inbox"})},[c]);return(0,tp.jsx)(Er,{theme:e,isLoading:!!(m&&p.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,tp.jsx)(lo,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:l==null?void 0:l({content:I,extensions:A,editable:!o,autofocus:!o,onUpdate:x})})}),Kc=(0,vt.memo)(xv);var tb=require("@tiptap/react");var Bt=require("react/jsx-runtime"),Yc=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,Bt.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Bt.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Bt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,Bt.jsx)(_a,{}),(0,Bt.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,Bt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,Bt.jsx)(ud,{}),(0,Bt.jsx)(Ua,{}),(0,Bt.jsx)(vd,{})]})]}),(0,Bt.jsx)(tb.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:R("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,Bt.jsx)(uo,{value:e,defaultValue:Vs}):(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(eb,{value:e}),(0,Bt.jsx)(Rr,{config:Q5})]})})]}):null,"InboxEditor");var rb=require("jotai"),Go=require("react");function Xc(e,t,r=500){let o=(0,rb.useSetAtom)(Qn),n=(0,Go.useRef)(),i=(0,Go.useRef)(void 0),s=(0,Go.useRef)(t);(0,Go.useEffect)(()=>{s.current=t},[t]);let l=(0,Go.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(s.current(i.current),i.current=void 0)},[]);return(0,Go.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,Go.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}a(Xc,"useDebouncedFlush");var ob=require("@hookform/resolvers/zod"),Pa=require("jotai"),fr=require("react"),nb=require("react-hook-form"),Ko=require("zod");var le=require("react/jsx-runtime"),Tv=Ko.z.object({enableButton:Ko.z.boolean().default(!0),buttonStyle:Ko.z.enum(["filled","outlined"]).default("filled"),buttonLabel:Ko.z.string().default("Try now"),buttonUrl:Ko.z.string().default(""),enableSecondaryButton:Ko.z.boolean().default(!1),secondaryButtonStyle:Ko.z.enum(["filled","outlined"]).default("outlined"),secondaryButtonLabel:Ko.z.string().default("Learn more"),secondaryButtonUrl:Ko.z.string().default("")}),wv=a(()=>{let e=(0,Pa.useAtomValue)(_e),[t,r]=(0,Pa.useAtom)(se),o=(0,Pa.useSetAtom)(wt),n=(0,fr.useRef)(!1),i=(0,fr.useRef)(null),s=(0,fr.useRef)(t);(0,fr.useEffect)(()=>{s.current=t},[t]);let l=(0,nb.useForm)({resolver:(0,ob.zodResolver)(Tv),defaultValues:{enableButton:!1,buttonStyle:"filled",buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonStyle:"outlined",secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,fr.useEffect)(()=>{if(!e)return;let p=a(()=>{let{doc:v}=e.state,h=null,g=[];if(v.descendants(C=>C.type.name==="buttonRow"&&!h?(h=C.attrs,!1):(C.type.name==="button"&&g.length<2&&g.push(C.attrs),!0)),n.current=!0,h){let{button1Label:C,button1Link:P,button1BackgroundColor:y,button2Label:b,button2Link:A,button2BackgroundColor:x}=h,I=l.getValues();I.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),I.buttonLabel!==(C||"Try now")&&l.setValue("buttonLabel",C||"Try now",{shouldDirty:!1}),I.buttonUrl!==(P||"")&&l.setValue("buttonUrl",P||"",{shouldDirty:!1});let T=y==="#ffffff"?"outlined":"filled";I.buttonStyle!==T&&l.setValue("buttonStyle",T,{shouldDirty:!1}),I.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),I.secondaryButtonLabel!==(b||"Learn more")&&l.setValue("secondaryButtonLabel",b||"Learn more",{shouldDirty:!1}),I.secondaryButtonUrl!==(A||"")&&l.setValue("secondaryButtonUrl",A||"",{shouldDirty:!1});let k=x==="#ffffff"?"outlined":"filled";I.secondaryButtonStyle!==k&&l.setValue("secondaryButtonStyle",k,{shouldDirty:!1})}else if(g.length>0){let C=g[0],P=l.getValues();P.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),P.buttonLabel!==(C.label||"Try now")&&l.setValue("buttonLabel",C.label||"Try now",{shouldDirty:!1}),P.buttonUrl!==(C.link||"")&&l.setValue("buttonUrl",C.link||"",{shouldDirty:!1});let y=C.backgroundColor==="#ffffff"?"outlined":"filled";if(P.buttonStyle!==y&&l.setValue("buttonStyle",y,{shouldDirty:!1}),g.length>1){let b=g[1];P.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),P.secondaryButtonLabel!==(b.label||"Learn more")&&l.setValue("secondaryButtonLabel",b.label||"Learn more",{shouldDirty:!1}),P.secondaryButtonUrl!==(b.link||"")&&l.setValue("secondaryButtonUrl",b.link||"",{shouldDirty:!1});let A=b.backgroundColor==="#ffffff"?"outlined":"filled";P.secondaryButtonStyle!==A&&l.setValue("secondaryButtonStyle",A,{shouldDirty:!1})}else P.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonStyle:"filled",buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonStyle:"outlined",secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return p(),e.on("update",p),()=>{e.off("update",p)}},[e,l]),(0,fr.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let p=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!p||!p.elements){n.current=!1;return}let v=p.elements.filter(h=>h.type==="action");if(v.length>0){let h=v[0],g=v[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),l.setValue("buttonStyle",h.style==="link"?"outlined":"filled"),g?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",g.content||"Learn more"),l.setValue("secondaryButtonUrl",g.href||""),l.setValue("secondaryButtonStyle",g.style==="link"?"outlined":"filled")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,fr.useCallback)(p=>{let v=s.current;if(!v||n.current)return;let h=v.elements.find(x=>x.type==="channel"&&x.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
194
+ `};t={...t,elements:[c,d,...s]}}return t},"getOrCreateInboxElement"),_5={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},$5=a(({value:e})=>{let{editor:t}=(0,U5.useCurrentEditor)(),r=(0,No.useSetAtom)(ze),o=(0,No.useAtomValue)(se),n=(0,No.useAtomValue)(ge),i=(0,vt.useRef)(!1);return(0,vt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,vt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,vt.useEffect)(()=>{t&&(r(t),Dr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,vt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=z5(o),l=Qe({version:"2022-01-01",elements:[s]},{channel:"inbox"}),c=Ce(l),u=Ce(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),mv=(0,vt.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,No.useAtomValue)(ge),p=(0,vt.useRef)(!0),y=(0,vt.useRef)(!1),h=(0,No.useSetAtom)(ke),[v,C]=(0,No.useAtom)(se),P=(0,No.useSetAtom)(lt),b=(0,No.useAtomValue)(Ut),g=(0,vt.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,vt.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let N=(0,vt.useMemo)(()=>[...Nr({variables:g,setSelectedNode:h,disableVariableAutocomplete:!0})].filter(E=>E!==void 0),[g,h,!0]),T=(0,vt.useCallback)(({editor:E})=>{if(!E||b)return;if(!v){let L=Ce(E.getJSON()),I=po(null,"inbox","",L),B={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:I.elements,...I.raw&&{raw:I.raw}}]};C(B),P(B);return}let w=E.getJSON(),k=Ce(w),x=po(v,"inbox","",k),A=St(v,{elements:x.elements,channel:"inbox",...x.raw&&{raw:x.raw}}),M=JSON.stringify(v.elements),S=JSON.stringify(A.elements);M!==S&&setTimeout(()=>{y.current&&(C(A),P(A))},100)},[v,C,P,b]),R=(0,vt.useMemo)(()=>{let E=z5(c);return Qe({version:"2022-01-01",elements:[E]},{channel:"inbox"})},[c]);return(0,Km.jsx)(wr,{theme:e,isLoading:!!(m&&p.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,Km.jsx)(no,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:l==null?void 0:l({content:R,extensions:N,editable:!o,autofocus:!o,onUpdate:T})})}),Zc=(0,vt.memo)(mv);var j5=require("@tiptap/react");var Ft=require("react/jsx-runtime"),qc=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,Ft.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Ft.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Ft.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,Ft.jsx)(Fa,{}),(0,Ft.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,Ft.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,Ft.jsx)(id,{}),(0,Ft.jsx)(Ba,{}),(0,Ft.jsx)(fd,{})]})]}),(0,Ft.jsx)(j5.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:D("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,Ft.jsx)(ao,{value:e,defaultValue:Rs}):(0,Ft.jsxs)(Ft.Fragment,{children:[(0,Ft.jsx)($5,{value:e}),(0,Ft.jsx)(Lr,{config:_5})]})})]}):null,"InboxEditor");var Z5=require("jotai"),Jo=require("react");function Jc(e,t,r=500){let o=(0,Z5.useSetAtom)(Jn),n=(0,Jo.useRef)(),i=(0,Jo.useRef)(void 0),s=(0,Jo.useRef)(t);(0,Jo.useEffect)(()=>{s.current=t},[t]);let l=(0,Jo.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(s.current(i.current),i.current=void 0)},[]);return(0,Jo.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,Jo.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}a(Jc,"useDebouncedFlush");var q5=require("@hookform/resolvers/zod"),ya=require("jotai"),pr=require("react"),J5=require("react-hook-form"),Go=require("zod");var le=require("react/jsx-runtime"),pv=Go.z.object({enableButton:Go.z.boolean().default(!0),buttonStyle:Go.z.enum(["filled","outlined"]).default("filled"),buttonLabel:Go.z.string().default("Try now"),buttonUrl:Go.z.string().default(""),enableSecondaryButton:Go.z.boolean().default(!1),secondaryButtonStyle:Go.z.enum(["filled","outlined"]).default("outlined"),secondaryButtonLabel:Go.z.string().default("Learn more"),secondaryButtonUrl:Go.z.string().default("")}),fv=a(()=>{let e=(0,ya.useAtomValue)(ze),[t,r]=(0,ya.useAtom)(se),o=(0,ya.useSetAtom)(lt),n=(0,pr.useRef)(!1),i=(0,pr.useRef)(null),s=(0,pr.useRef)(t);(0,pr.useEffect)(()=>{s.current=t},[t]);let l=(0,J5.useForm)({resolver:(0,q5.zodResolver)(pv),defaultValues:{enableButton:!1,buttonStyle:"filled",buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonStyle:"outlined",secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,pr.useEffect)(()=>{if(!e)return;let p=a(()=>{let{doc:y}=e.state,h=null,v=[];if(y.descendants(C=>C.type.name==="buttonRow"&&!h?(h=C.attrs,!1):(C.type.name==="button"&&v.length<2&&v.push(C.attrs),!0)),n.current=!0,h){let{button1Label:C,button1Link:P,button1BackgroundColor:b,button2Label:g,button2Link:N,button2BackgroundColor:T}=h,R=l.getValues();R.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),R.buttonLabel!==(C||"Try now")&&l.setValue("buttonLabel",C||"Try now",{shouldDirty:!1}),R.buttonUrl!==(P||"")&&l.setValue("buttonUrl",P||"",{shouldDirty:!1});let E=b==="#ffffff"?"outlined":"filled";R.buttonStyle!==E&&l.setValue("buttonStyle",E,{shouldDirty:!1}),R.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),R.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),R.secondaryButtonUrl!==(N||"")&&l.setValue("secondaryButtonUrl",N||"",{shouldDirty:!1});let w=T==="#ffffff"?"outlined":"filled";R.secondaryButtonStyle!==w&&l.setValue("secondaryButtonStyle",w,{shouldDirty:!1})}else if(v.length>0){let C=v[0],P=l.getValues();P.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),P.buttonLabel!==(C.label||"Try now")&&l.setValue("buttonLabel",C.label||"Try now",{shouldDirty:!1}),P.buttonUrl!==(C.link||"")&&l.setValue("buttonUrl",C.link||"",{shouldDirty:!1});let b=C.backgroundColor==="#ffffff"?"outlined":"filled";if(P.buttonStyle!==b&&l.setValue("buttonStyle",b,{shouldDirty:!1}),v.length>1){let g=v[1];P.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),P.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),P.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1});let N=g.backgroundColor==="#ffffff"?"outlined":"filled";P.secondaryButtonStyle!==N&&l.setValue("secondaryButtonStyle",N,{shouldDirty:!1})}else P.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonStyle:"filled",buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonStyle:"outlined",secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return p(),e.on("update",p),()=>{e.off("update",p)}},[e,l]),(0,pr.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let p=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!p||!p.elements){n.current=!1;return}let y=p.elements.filter(h=>h.type==="action");if(y.length>0){let h=y[0],v=y[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),l.setValue("buttonStyle",h.style==="link"?"outlined":"filled"),v?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",v.content||"Learn more"),l.setValue("secondaryButtonUrl",v.href||""),l.setValue("secondaryButtonStyle",v.style==="link"?"outlined":"filled")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,pr.useCallback)(p=>{let y=s.current;if(!y||n.current)return;let h=y.elements.find(T=>T.type==="channel"&&T.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
195
195
  `,text_style:"h2"},{type:"text",content:`
196
- `}]}),h.elements||(h.elements=[]);let C=[...h.elements.filter(x=>x.type!=="action")];if(p.enableButton){let x={type:"action",content:p.buttonLabel,background_color:p.buttonStyle==="outlined"?"#ffffff":"#000000",color:p.buttonStyle==="outlined"?"#000000":"#ffffff",border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:p.buttonUrl,style:p.buttonStyle==="outlined"?"link":"button"};C.push(x)}if(p.enableSecondaryButton){let x={type:"action",content:p.secondaryButtonLabel,background_color:p.secondaryButtonStyle==="outlined"?"#ffffff":"#000000",color:p.secondaryButtonStyle==="outlined"?"#000000":"#ffffff",border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:p.secondaryButtonUrl,style:p.secondaryButtonStyle==="outlined"?"link":"button"};C.push(x)}let P={...h,elements:C},y=v.elements.findIndex(x=>x.type==="channel"&&x.channel==="inbox"),b=[...v.elements];y!==-1?b[y]=P:b.push(P);let A={...v,elements:b};r(A),o(A)},[r,o]),u=(0,fr.useCallback)(p=>{if(!e)return!1;let{doc:v}=e.state,h=null,g=[];v.descendants((P,y)=>P.type.name==="buttonRow"&&h===null?(h=y,!1):(P.type.name==="button"&&g.push({pos:y,attrs:P.attrs}),!0));let C=a((P,y)=>{let b=v.nodeAt(P);return b?(e.commands.command(({tr:A})=>(A.setNodeMarkup(P,b.type,y),!0)),!0):!1},"applyAttrs");if(h!==null){let P=v.nodeAt(h);if(!P)return!1;let y={...P.attrs,button1Label:p.buttonLabel,button1Link:p.buttonUrl,button1BackgroundColor:p.buttonStyle==="outlined"?"#ffffff":"#000000",button1TextColor:p.buttonStyle==="outlined"?"#000000":"#ffffff",button2Label:p.secondaryButtonLabel,button2Link:p.secondaryButtonUrl,button2BackgroundColor:p.secondaryButtonStyle==="outlined"?"#ffffff":"#000000",button2TextColor:p.secondaryButtonStyle==="outlined"?"#000000":"#ffffff"};return C(h,y)}if(g.length>0){let[P,y]=g,b={...P.attrs,label:p.buttonLabel,link:p.buttonUrl,backgroundColor:p.buttonStyle==="outlined"?"#ffffff":"#000000",textColor:p.buttonStyle==="outlined"?"#000000":"#ffffff"},A=C(P.pos,b),x=!0;if(y){let I={...y.attrs,label:p.secondaryButtonLabel,link:p.secondaryButtonUrl,backgroundColor:p.secondaryButtonStyle==="outlined"?"#ffffff":"#000000",textColor:p.secondaryButtonStyle==="outlined"?"#000000":"#ffffff"};x=C(y.pos,I)}return A&&x}return!1},[e]),d=(0,fr.useCallback)(p=>{if(n.current)return;let v=i.current;if(i.current=p,!v||v.enableButton!==p.enableButton||v.enableSecondaryButton!==p.enableSecondaryButton){c(p);return}u(p)||c(p)},[c,u]),f=Xc("inbox-sidebar",d,500),m=(0,fr.useCallback)(()=>{let p=l.getValues();f(p)},[l,f]);return(0,le.jsx)(et,{...l,children:(0,le.jsxs)("form",{onChange:m,children:[(0,le.jsx)("div",{className:"courier-pb-4",children:(0,le.jsx)(J,{control:l.control,name:"enableButton",render:({field:p})=>(0,le.jsxs)(Z,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,le.jsx)(Uo,{className:"!courier-m-0",children:"Enable button"}),(0,le.jsx)(q,{children:(0,le.jsx)(Ji,{checked:p.value,onCheckedChange:p.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(J,{control:l.control,name:"buttonStyle",render:({field:p})=>(0,le.jsxs)(Z,{className:"courier-mb-4",children:[(0,le.jsx)(q,{children:(0,le.jsxs)(er,{type:"single",value:p.value,onValueChange:v=>{p.onChange(v),m()},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",children:[(0,le.jsx)(tt,{size:"sm",value:"filled",className:"courier-w-full courier-h-7",children:"Filled"}),(0,le.jsx)(tt,{size:"sm",value:"outlined",className:"courier-w-full courier-h-7",children:"Outlined"})]})}),(0,le.jsx)(K,{})]})}),(0,le.jsx)(J,{control:l.control,name:"buttonUrl",render:({field:p})=>(0,le.jsxs)(Z,{className:"courier-mb-6",children:[(0,le.jsx)(Uo,{children:"Action URL"}),(0,le.jsx)(q,{children:(0,le.jsx)(pe,{placeholder:"https://example.com",...p})}),(0,le.jsx)(K,{})]})})]}),(0,le.jsx)(ye,{className:"courier-mb-6"}),(0,le.jsx)(J,{control:l.control,name:"enableSecondaryButton",render:({field:p})=>(0,le.jsxs)(Z,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,le.jsx)(Uo,{className:"!courier-m-0",children:"Enable secondary button"}),(0,le.jsx)(q,{children:(0,le.jsx)(Ji,{checked:p.value,onCheckedChange:p.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(J,{control:l.control,name:"secondaryButtonStyle",render:({field:p})=>(0,le.jsxs)(Z,{className:"courier-mb-4",children:[(0,le.jsx)(q,{children:(0,le.jsxs)(er,{type:"single",value:p.value,onValueChange:v=>{p.onChange(v),m()},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",children:[(0,le.jsx)(tt,{size:"sm",value:"filled",className:"courier-w-full courier-h-7",children:"Filled"}),(0,le.jsx)(tt,{size:"sm",value:"outlined",className:"courier-w-full courier-h-7",children:"Outlined"})]})}),(0,le.jsx)(K,{})]})}),(0,le.jsx)(J,{control:l.control,name:"secondaryButtonUrl",render:({field:p})=>(0,le.jsxs)(Z,{className:"courier-mb-4",children:[(0,le.jsx)(Uo,{children:"Action URL"}),(0,le.jsx)(q,{children:(0,le.jsx)(pe,{placeholder:"https://example.com",...p})}),(0,le.jsx)(K,{})]})})]})]})})},"SideBarComponent"),Qc=(0,fr.memo)(wv);var ib=require("jotai");var bn=require("react/jsx-runtime"),ab=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let s=(0,ib.useAtomValue)(se);return(0,bn.jsx)(Kc,{value:s,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,bn.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,bn.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,bn.jsx)(Yc,{...l})}),(0,bn.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,bn.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,bn.jsx)(Qc,{})})})]}),...i})},"InboxLayout");var sb=require("@tiptap/react"),Io=require("jotai"),Ct=require("react");var rp=require("react/jsx-runtime"),lb=a(({value:e})=>{let{editor:t}=(0,sb.useCurrentEditor)(),r=(0,Io.useSetAtom)(_e),o=(0,Io.useAtomValue)(se),n=(0,Io.useAtomValue)(be),i=(0,Ct.useRef)(!1);return(0,Ct.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,Ct.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ct.useEffect)(()=>{t&&(r(t),Hr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ct.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=cb(o),l=s.type==="channel"&&"elements"in s&&s.elements||Ii;l=l.map(m=>m.type==="meta"&&"title"in m?{type:"text",content:m.title||`
197
- `,text_style:"h2"}:m);let u=Qe({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=Te(u),f=Te(t.getJSON());JSON.stringify(d)!==JSON.stringify(f)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Ii=[{type:"meta",title:""},{type:"text",content:`
198
- `}],cb=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="push");return t||(t={type:"channel",channel:"push",elements:Ii}),t},"getOrCreatePushElement"),ub={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},Ev=(0,Ct.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,Io.useAtomValue)(be),p=(0,Ct.useRef)(!0),v=(0,Ct.useRef)(!1),h=(0,Io.useSetAtom)(Me),[g,C]=(0,Io.useAtom)(se),P=(0,Io.useSetAtom)(wt),y=(0,Io.useAtomValue)(Ut),b=(0,Ct.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,Ct.useEffect)(()=>(v.current=!0,()=>{v.current=!1}),[]);let A=(0,Ct.useMemo)(()=>[...Sr({variables:b,setSelectedNode:h,disableVariableAutocomplete:!0})].filter(T=>T!==void 0),[b,h,!0]),x=(0,Ct.useCallback)(({editor:T})=>{if(y)return;if(!g){let D=Te(T.getJSON()),L=D[0],B="",V=D;L&&L.type==="text"&&"text_style"in L&&L.text_style==="h2"&&"content"in L&&(B=L.content.trim(),V=D.slice(1));let j={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:bo(null,"push",B,V).elements}]};C(j),P(j);return}let k=Te(T.getJSON()),w=k[0],E="",N=k;w&&w.type==="text"&&"text_style"in w&&w.text_style==="h2"&&"content"in w&&(E=w.content.trim(),N=k.slice(1));let M=bo(g,"push",E,N),S=At(g,{channel:"push",elements:M.elements});JSON.stringify(g)!==JSON.stringify(S)&&(C(S),P(S))},[g,C,P,y]),I=(0,Ct.useMemo)(()=>{if(m!==!1)return null;let T=c==null?void 0:c.elements.find(E=>E.type==="channel"&&E.channel==="push");!T&&g&&(T=cb(g));let k=(T==null?void 0:T.type)==="channel"&&"elements"in T&&T.elements||Ii;return k=k.map(E=>E.type==="meta"&&"title"in E?{type:"text",content:E.title||`
199
- `,text_style:"h2"}:E),Qe({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:k}]})},[c,g,m]);return(0,rp.jsx)(Er,{theme:e,isLoading:!!(m&&p.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,rp.jsx)(lo,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:l==null?void 0:l({content:I,extensions:A,editable:!o,autofocus:!o,onUpdate:x})})}),eu=(0,Ct.memo)(Ev);var db=require("@tiptap/react");var gr=require("react/jsx-runtime"),tu=a(({children:e})=>(0,gr.jsxs)("div",{className:"courier-relative",children:[(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,gr.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,gr.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,gr.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,gr.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,gr.jsx)(Mf,{}),(0,gr.jsx)(Nf,{}),(0,gr.jsx)(kf,{})]})]}),(0,gr.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var Gr=require("react/jsx-runtime"),ru=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,Gr.jsxs)(tu,{children:[(0,Gr.jsxs)("div",{className:R("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,Gr.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,Gr.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,Gr.jsx)(db.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:R("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,Gr.jsx)(uo,{value:l,defaultValue:Ii}):(0,Gr.jsxs)(Gr.Fragment,{children:[(0,Gr.jsx)(lb,{value:l}),(0,Gr.jsx)(Rr,{config:ub})]})})]})},"PushEditor");var mb=require("jotai");var ou=require("react/jsx-runtime"),pb=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let s=(0,mb.useAtomValue)(se);return(0,ou.jsx)(eu,{value:s,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,ou.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,ou.jsx)(ru,{...l})}),...i})},"PushLayout");var fb=require("@tiptap/react"),Br=require("jotai"),Be=require("react");var ka=require("react/jsx-runtime"),Os=[{type:"text",content:`
200
- `}],gb=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="slack");return t||(t={type:"channel",channel:"slack",elements:Os}),t},"getOrCreateSlackElement"),hb=a(({value:e})=>{let{editor:t}=(0,fb.useCurrentEditor)(),r=(0,Br.useSetAtom)(_e),o=(0,Br.useAtomValue)(se),n=(0,Br.useAtomValue)(be),i=(0,Br.useAtomValue)(Me),s=(0,Be.useRef)(!1),l=(0,Be.useRef)(!1);return(0,Be.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Be.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Be.useEffect)(()=>{t&&(r(t),Hr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Be.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Be.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Be.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=gb(o),u=Qe({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=Te(u),f=Te(t.getJSON());JSON.stringify(d)!==JSON.stringify(f)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),bb={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"}},Pv=(0,Be.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,Br.useAtomValue)(be),p=(0,Br.useAtomValue)(Ut),v=(0,Br.useAtomValue)(_e),h=(0,Br.useAtomValue)(Cr),[g,C]=(0,Br.useAtom)(Me),[P,y]=(0,Br.useAtom)(se),b=(0,Br.useSetAtom)(wt),A=(0,Be.useRef)(!0),x=(0,Be.useRef)(!1),I=(0,Be.useRef)(h),T=(0,Be.useRef)(null),[k,w]=(0,Be.useState)({Sidebar:["text","divider","button"],Editor:[]});Ca({items:k,setItems:w});let{syncEditorItems:E}=Hc({setItems:w,rafId:T});(0,Be.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]),(0,Be.useEffect)(()=>{I.current=h},[h]),(0,Be.useEffect)(()=>{m===!1&&P&&setTimeout(()=>{v&&!v.isDestroyed&&E(v)},300)},[m,P,v,E]);let N=(0,Be.useCallback)(()=>!I.current,[]),M=(0,Be.useMemo)(()=>[...Sr({variables:r,setSelectedNode:C,shouldHandleClick:N,disableVariableAutocomplete:!0})].filter(L=>L!==void 0),[r,C,N,!0]),S=(0,Be.useCallback)(({editor:L})=>{if(!L||p)return;if(!P){let Q={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:Te(L.getJSON())}]};y(Q),b(Q);return}let B=L.getJSON(),V=Te(B),O=At(P,{elements:V,channel:"slack"}),j=JSON.stringify(P.elements),W=JSON.stringify(O.elements);j!==W&&(y(O),b(O))},[P,y,b,p]),D=(0,Be.useMemo)(()=>{let L=gb(c);return Qe({version:"2022-01-01",elements:[L]},{channel:"slack"})},[c]);return(0,ka.jsx)(Er,{theme:e,isLoading:!!(m&&A.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,ka.jsx)(lo,{hidePublish:t,channels:n,routing:i}),ref:d,...u,children:(0,ka.jsx)(ka.Fragment,{children:l==null?void 0:l({content:D,extensions:M,editable:!o,autofocus:!o,onUpdate:S,items:k,selectedNode:g,slackEditor:v})})})}),nu=(0,Be.memo)(Pv);var Cb=require("@tiptap/react");var Ke=require("react/jsx-runtime"),kv=a(()=>(0,Ke.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Ke.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,Ke.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,Ke.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"})]}),"TextSkeleton"),Mv=a(()=>(0,Ke.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-lg",children:(0,Ke.jsx)(Ga,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),yb=a(()=>(0,Ke.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Ke.jsx)(Mv,{}),(0,Ke.jsx)(kv,{})]}),"InteractionSkeleton"),vb=a(({children:e,className:t})=>(0,Ke.jsxs)("div",{className:R("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ke.jsx)(yb,{}),(0,Ke.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ke.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Ke.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Ke.jsx)(Ja,{color:"#FFFFFF"})})}),(0,Ke.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ke.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Ke.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900",children:"Circle"}),(0,Ke.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 courier-text-gray-700",children:"APP"}),(0,Ke.jsx)("span",{className:"courier-text-xs courier-text-gray-500",children:"Now"})]}),(0,Ke.jsx)("div",{className:"courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Ke.jsx)(yb,{})]}),"SlackFrame");var iu=require("react");var Lo=require("react/jsx-runtime"),au=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,iu.useRef)(null);return(0,iu.useEffect)(()=>{let l=s.current;if(!(!l||i))return _r({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Lo.jsx)(vb,{children:(0,Lo.jsx)("div",{ref:s,children:(0,Lo.jsx)(Cb.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:R("courier-slack-editor")},immediatelyRender:!1,children:i?(0,Lo.jsx)(uo,{value:e,defaultValue:Os}):(0,Lo.jsxs)(Lo.Fragment,{children:[(0,Lo.jsx)(hb,{value:e}),(0,Lo.jsx)(Rr,{config:bb})]})})})}):null},"SlackEditor");var Pb=require("jotai");var xb=require("lucide-react");var nr=require("react/jsx-runtime"),su=a(({items:e,label:t,editor:r})=>(0,nr.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,nr.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,nr.jsxs)(nr.Fragment,{children:[(0,nr.jsx)("p",{children:t}),(0,nr.jsx)(ye,{className:"courier-my-4"})]}),(0,nr.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,nr.jsx)(Ea,{id:o.toString(),editor:r,children:(0,nr.jsxs)("div",{className:R("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,nr.jsx)(xb.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,nr.jsx)(Ln,{draggable:!0}),o==="divider"&&(0,nr.jsx)(In,{draggable:!0}),o==="button"&&(0,nr.jsx)(Sn,{draggable:!0})]})},o))})]})}),"SlackSideBar");var Tb=require("@hookform/resolvers/zod"),wb=require("react-hook-form");var Ro=require("react/jsx-runtime"),Eb=a(({element:e,editor:t})=>{var s,l;let r=(0,wb.useForm)({resolver:(0,Tb.zodResolver)(Al),defaultValues:{...$e,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"button"}),n=((l=(s=t==null?void 0:t.extensionManager.extensions.find(c=>c.name==="variableSuggestion"))==null?void 0:s.options)==null?void 0:l.variables)||{},i=$r(n);return e?(0,Ro.jsxs)(et,{...r,children:[(0,Ro.jsx)(rr,{type:"button"}),(0,Ro.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Ro.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,Ro.jsx)(J,{control:r.control,name:"link",render:({field:c})=>(0,Ro.jsxs)(Z,{children:[(0,Ro.jsx)(q,{children:(0,Ro.jsx)(kr,{as:"Textarea",...c,variables:i,onChange:u=>{c.onChange(u),o({...r.getValues(),link:u.target.value})}})}),(0,Ro.jsx)(K,{})]})})]})]}):null},"SlackButtonForm");var op=require("react/jsx-runtime"),lu=a(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,op.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,op.jsx)(Eb,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var np=require("react");var Fr=require("react/jsx-runtime"),Nv=(0,np.forwardRef)(({children:e,className:t,...r},o)=>(0,Fr.jsx)("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Av=(0,np.forwardRef)(({children:e,...t},r)=>(0,Fr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),kb=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,Pb.useAtomValue)(se);return(0,Fr.jsx)(nu,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:s=>{var l;return(0,Fr.jsxs)(Un,{children:[(0,Fr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Fr.jsx)(Nv,{children:(0,Fr.jsx)(Av,{children:(0,Fr.jsx)(au,{...s})})})}),(0,Fr.jsx)(zn,{children:(0,Fr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Fr.jsx)(lu,{element:s.selectedNode,editor:s.slackEditor,defaultElement:(0,Fr.jsx)(su,{items:s.items.Sidebar,label:"Blocks library",editor:(l=s.slackEditor)!=null?l:void 0})})})})]})}})},"SlackLayout");var Mb=require("@tiptap/react"),Do=require("jotai"),Ze=require("react"),Nb=require("sms-segments-calculator");var cu=require("react/jsx-runtime"),yn=[{type:"text",content:`
201
- `}],Ab=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="sms");return t||(t={type:"channel",channel:"sms",elements:yn}),t},"getOrCreateSMSElement"),Sb=a(({value:e})=>{var c;let{editor:t}=(0,Mb.useCurrentEditor)(),r=(0,Do.useSetAtom)(_e),o=(0,Do.useAtomValue)(se),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,Ze.useMemo)(()=>new Nb.SegmentedMessage(n),[n]),s=(0,Do.useAtomValue)(be),l=(0,Ze.useRef)(!1);return(0,Ze.useEffect)(()=>{s&&(l.current=!1)},[s]),(0,Ze.useEffect)(()=>{!t||s!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,s]),(0,Ze.useEffect)(()=>{t&&(r(t),Hr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ze.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=Ab(o),f={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||yn},m=Qe({version:"2022-01-01",elements:[f]}),p=Te(m),v=Te(t.getJSON());JSON.stringify(p)!==JSON.stringify(v)&&setTimeout(()=>{t.isFocused||t.commands.setContent(m)},1)},[t,o]),(0,cu.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),Ib={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},Sv=(0,Ze.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,render:s,headerRenderer:l,value:c,...u},d)=>{let m=(0,Do.useAtomValue)(be),p=(0,Ze.useRef)(!0),v=(0,Ze.useRef)(!1),h=(0,Do.useSetAtom)(Me),[g,C]=(0,Do.useAtom)(se),P=(0,Do.useSetAtom)(wt),y=(0,Do.useAtomValue)(Ut),b=(0,Ze.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,Ze.useEffect)(()=>(v.current=!0,()=>{v.current=!1}),[]);let A=(0,Ze.useMemo)(()=>[...Sr({variables:b,setSelectedNode:h,disableVariableAutocomplete:!0})].filter(E=>E!==void 0),[b,h,!0]),x=(0,Ze.useRef)(!1),I=(0,Ze.useCallback)(({editor:E})=>{if(y)return;if(!g){let D=Te(E.getJSON()),L=qs(D),B={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:L.length>0?L:yn}]};x.current=!0,C(B),P(B);return}let N=Te(E.getJSON()),M=qs(N),S=At(g,{channel:"sms",elements:M.length>0?M:yn});JSON.stringify(g)!==JSON.stringify(S)&&(x.current=!0,C(S),P(S))},[g,C,P,y]),[T,k]=(0,Ze.useState)(null),w=(0,Ze.useCallback)(E=>{if(!E)return null;let N=E==null?void 0:E.elements.find(D=>D.type==="channel"&&D.channel==="sms");N||(N=Ab(E));let S={type:"channel",channel:"sms",elements:(N==null?void 0:N.type)==="channel"&&"elements"in N&&N.elements||yn};return Qe({version:"2022-01-01",elements:[S]})},[]);return(0,Ze.useEffect)(()=>{if(m!==!1)return;if(x.current){x.current=!1;return}let E=c!=null?c:g,N=w(E);N&&k(N)},[c,g,w,m]),(0,cu.jsx)(Er,{theme:e,isLoading:!!(m&&p.current),Header:l?l({hidePublish:t,channels:n,routing:i}):(0,cu.jsx)(lo,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:s==null?void 0:s({content:T,extensions:A,editable:!o,autofocus:!o,onUpdate:I})})}),uu=(0,Ze.memo)(Sv);var Lb=require("@tiptap/react");var Ho=require("react/jsx-runtime"),du=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,Ho.jsx)(tu,{children:(0,Ho.jsx)("div",{className:R("courier-sms-editor",i),children:(0,Ho.jsx)(Lb.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,Ho.jsx)(uo,{value:l,defaultValue:yn}):(0,Ho.jsxs)(Ho.Fragment,{children:[(0,Ho.jsx)(Sb,{value:l}),(0,Ho.jsx)(Rr,{config:Ib})]})})})})},"SMSEditor");var Rb=require("jotai");var mu=require("react/jsx-runtime"),Db=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,dataMode:i,...s})=>{let l=(0,Rb.useAtomValue)(se);return(0,mu.jsx)(uu,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,dataMode:i,render:c=>(0,mu.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,mu.jsx)(du,{...c})}),...s})},"SMSLayout");var Hb=require("@tiptap/react"),Vr=require("jotai"),Se=require("react");var Ma=require("react/jsx-runtime"),Ws=[{type:"text",content:`
202
- `}],Bb=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="msteams");return t||(t={type:"channel",channel:"msteams",elements:Ws}),t},"getOrCreateMSTeamsElement"),Fb=a(({value:e})=>{let{editor:t}=(0,Hb.useCurrentEditor)(),r=(0,Vr.useSetAtom)(_e),o=(0,Vr.useAtomValue)(se),n=(0,Vr.useAtomValue)(be),i=(0,Vr.useAtomValue)(Me),s=(0,Se.useRef)(!1),l=(0,Se.useRef)(!1);return(0,Se.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Se.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Se.useEffect)(()=>{t&&(r(t),Hr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Se.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Se.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Se.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=Bb(o),u=Qe({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=Te(u),f=Te(t.getJSON());JSON.stringify(d)!==JSON.stringify(f)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),Vb={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"}},Iv=(0,Se.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,Vr.useAtomValue)(be),p=(0,Vr.useAtomValue)(Ut),v=(0,Vr.useAtomValue)(_e),h=(0,Vr.useAtomValue)(Cr),[g,C]=(0,Vr.useAtom)(Me),[P,y]=(0,Vr.useAtom)(se),b=(0,Vr.useSetAtom)(wt),A=(0,Se.useRef)(!0),x=(0,Se.useRef)(!1),I=(0,Se.useRef)(h),[T,k]=(0,Se.useState)({Sidebar:["text","divider"],Editor:[]}),w=(0,Se.useRef)(null);Ca({items:T,setItems:k});let E=(0,Se.useCallback)(L=>{w.current&&cancelAnimationFrame(w.current),setTimeout(()=>{w.current=requestAnimationFrame(()=>{try{let B=L==null?void 0:L.view.dom;if(!B){console.warn("syncEditorItems: Editor DOM element not found");return}let V=B.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),O=[];V.forEach(j=>{let W=j.dataset.id;W&&O.push(W)}),k(j=>({Editor:O,Sidebar:j.Sidebar}))}catch(B){console.error("Error syncing editor items:",B),k(V=>({...V}))}})},50)},[]);(0,Se.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]),(0,Se.useEffect)(()=>{I.current=h},[h]),(0,Se.useEffect)(()=>{let L=a(()=>{v&&E(v)},"updateItems");v==null||v.on("update",L),v==null||v.on("selectionUpdate",L),v==null||v.on("create",L),v==null||v.on("transaction",L),v&&!v.isDestroyed&&L();let B=a(V=>{L()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",B),()=>{v==null||v.off("update",L),v==null||v.off("selectionUpdate",L),v==null||v.off("create",L),v==null||v.off("transaction",L),document.removeEventListener("node-duplicated",B),w.current&&cancelAnimationFrame(w.current)}},[v,E]),(0,Se.useEffect)(()=>{m===!1&&P&&setTimeout(()=>{v&&!v.isDestroyed&&E(v)},300)},[m,P,v,E]);let N=(0,Se.useCallback)(()=>!I.current,[]),M=(0,Se.useMemo)(()=>[...Sr({variables:r,setSelectedNode:C,shouldHandleClick:N,disableVariableAutocomplete:!0})].filter(L=>L!==void 0),[r,C,N,!0]),S=(0,Se.useCallback)(({editor:L})=>{if(!L||p)return;if(!P){let Q={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:Te(L.getJSON())}]};y(Q),b(Q);return}let B=L.getJSON(),V=Te(B),O=At(P,{elements:V,channel:"msteams"}),j=JSON.stringify(P.elements),W=JSON.stringify(O.elements);j!==W&&(y(O),b(O))},[P,y,b,p]),D=(0,Se.useMemo)(()=>{let L=Bb(c);return Qe({version:"2022-01-01",elements:[L]},{channel:"msteams"})},[c]);return(0,Ma.jsx)(Er,{theme:e,isLoading:!!(m&&A.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,Ma.jsx)(lo,{hidePublish:t,channels:n,routing:i}),ref:d,...u,children:(0,Ma.jsx)(Ma.Fragment,{children:l==null?void 0:l({content:D,extensions:M,editable:!o,autofocus:!o,onUpdate:S,items:T,selectedNode:g,msteamsEditor:v})})})}),pu=(0,Se.memo)(Iv);var Wb=require("@tiptap/react");var Xe=require("react/jsx-runtime"),Lv=a(()=>(0,Xe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-full",children:(0,Xe.jsx)(Ga,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),Rv=a(()=>(0,Xe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Xe.jsx)(Lv,{}),(0,Xe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Xe.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] courier-rounded-[12px]"}),(0,Xe.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),Dv=a(()=>(0,Xe.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Xe.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Xe.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),Ob=a(({children:e,className:t})=>(0,Xe.jsxs)("div",{className:R("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Xe.jsx)(Rv,{}),(0,Xe.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Xe.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Xe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Xe.jsx)(Ja,{color:"#FFFFFF"})})}),(0,Xe.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Xe.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Xe.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3]",children:"Circle"})}),(0,Xe.jsx)("div",{className:"courier-bg-[#F5F5F5] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,Xe.jsx)(Dv,{})]}),"MSTeamsFrame");var fu=require("react");var Bo=require("react/jsx-runtime"),gu=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,fu.useRef)(null);return(0,fu.useEffect)(()=>{let l=s.current;if(!(!l||i))return _r({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Bo.jsx)(Ob,{children:(0,Bo.jsx)("div",{ref:s,children:(0,Bo.jsx)(Wb.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:R("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,Bo.jsx)(uo,{value:e,defaultValue:Ws}):(0,Bo.jsxs)(Bo.Fragment,{children:[(0,Bo.jsx)(Fb,{value:e}),(0,Bo.jsx)(Rr,{config:Vb})]})})})}):null},"MSTeamsEditor");var zb=require("jotai");var Ub=require("lucide-react");var ir=require("react/jsx-runtime"),hu=a(({items:e,label:t,editor:r})=>(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,ir.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,ir.jsxs)(ir.Fragment,{children:[(0,ir.jsx)("p",{children:t}),(0,ir.jsx)(ye,{className:"courier-my-4"})]}),(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,ir.jsx)(Ea,{id:o.toString(),editor:r,children:(0,ir.jsxs)("div",{className:R("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,ir.jsx)(Ub.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,ir.jsx)(Ln,{draggable:!0}),o==="divider"&&(0,ir.jsx)(In,{draggable:!0}),o==="button"&&(0,ir.jsx)(Sn,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");var ip=require("react");var Kr=require("react/jsx-runtime"),Hv=(0,ip.forwardRef)(({children:e,className:t,...r},o)=>(0,Kr.jsx)("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Bv=(0,ip.forwardRef)(({children:e,...t},r)=>(0,Kr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),_b=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,zb.useAtomValue)(se);return(0,Kr.jsx)(pu,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:s=>{var l;return(0,Kr.jsxs)(Un,{children:[(0,Kr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Kr.jsx)(Hv,{children:(0,Kr.jsx)(Bv,{children:(0,Kr.jsx)(gu,{...s})})})}),(0,Kr.jsx)(zn,{children:(0,Kr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Kr.jsx)(hu,{items:s.items.Sidebar,label:"Blocks library",editor:(l=s.msteamsEditor)!=null?l:void 0})})})]})}})},"MSTeamsLayout");var $b={sms:{elements:yn},push:{elements:Ii},inbox:{elements:Vs},slack:{elements:Os},email:{elements:Rs},msteams:{elements:Ws}},jb=a(e=>{var t;return(t=$b[e])!=null?t:$b.email},"getChannelDefaults"),Fv=a((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["email"]},"resolveChannels"),bu=a(({channels:e=["email"],routing:t})=>{let[r,o]=(0,Or.useState)([]),n=(0,vn.useAtomValue)(se),i=(0,vn.useSetAtom)(se),s=(0,vn.useSetAtom)(wt),[l,c]=(0,vn.useAtom)(kn),u=(0,vn.useSetAtom)(Me),d=(0,vn.useAtomValue)(be),f=Fv(t,e),m=(0,Or.useRef)(f);m.current=f,(0,Or.useEffect)(()=>{if(d||n!=null&&n.elements)return;let P=m.current.map(y=>Pn.find(b=>b.value===y)).filter(y=>!!y);o(P),P.length>0&&!l&&c(P[0].value)},[n,d,c,l]),(0,Or.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let C=m.current,P=n.elements.filter(b=>b.type==="channel").map(b=>b.channel).filter(b=>C.includes(b)),y=C.filter(b=>P.includes(b)).map(b=>Pn.find(A=>A.value===b)).filter(b=>!!b);o(y)},[n,d]),(0,Or.useEffect)(()=>{var y;if(d||r.length===0)return;let C=r.some(b=>b.value===l),P=(y=n==null?void 0:n.elements)==null?void 0:y.some(b=>b.type==="channel"&&b.channel===l);!C&&!P&&c(r[0].value)},[r,l,c,d,n]);let p=(0,Or.useMemo)(()=>(f==null?void 0:f.filter(C=>!r.some(P=>P.value===C)).map(C=>Pn.find(P=>P.value===C)).filter(C=>!!C))||[],[r,f]),v=(0,Or.useCallback)(C=>{let P=[],y,{elements:b,raw:A}=jb(C);if(P=b,y=A,!n){let T=[];for(let E of r){let{elements:N,raw:M}=jb(E.value),S={type:"channel",channel:E.value,elements:N};M&&(S.raw=M),T.push(S)}let k={type:"channel",channel:C,elements:P};y&&(k.raw=y),T.push(k);let w={version:"2022-01-01",elements:T};i(w),s(w),c(C);return}let I=At(n,{elements:P,channel:y?{channel:C,raw:y}:C});i(I),s(I),c(C)},[n,i,s,c,r]),h=(0,Or.useCallback)(C=>{if(!n)return;let P=n.elements.filter(A=>A.type==="channel"?A.channel!==C:!0),y={...n,elements:P};i(y),s(y),u(null);let b=r.filter(A=>A.value!==C);l===C&&b.length>0&&c(b[0].value)},[n,i,s,r,l,c,u]),g=(0,Or.useMemo)(()=>[...r,...p],[r,p]);return{enabledChannels:r,disabledChannels:p,channel:l,channelOptions:g,setChannel:c,addChannel:v,removeChannel:h}},"useChannels");var Ie=require("react/jsx-runtime"),lo=a(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,Yo.useRef)(null),n=(0,Cn.useAtomValue)(Ot),i=(0,Cn.useAtomValue)(be),s=(0,Cn.useAtomValue)(ae),{publishTemplate:l,isTemplatePublishing:c}=Ui(),[u,d]=(0,Cn.useAtom)(Fi),f=(0,Cn.useSetAtom)(Wo),m=(0,Cn.useAtomValue)(Wo),{enabledChannels:p,disabledChannels:v,channel:h,setChannel:g,addChannel:C,removeChannel:P}=bu({channels:t,routing:r});(0,Yo.useEffect)(()=>{n===!0&&d(null)},[n,d]);let y=(0,Yo.useCallback)(()=>{m&&f(!1),l()},[l,m,f]),b=(0,Yo.useCallback)(T=>{m&&f(!1),g(T)},[m,f,g]),A=(0,Yo.useCallback)(T=>{m&&f(!1),C(T)},[m,f,C]),x=(0,Yo.useCallback)(T=>{m&&f(!1),P(T)},[m,f,P]),I=(0,Yo.useCallback)(()=>{m&&f(!1)},[m,f]);return(0,Ie.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:I,children:[(0,Ie.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,Ie.jsx)(rl,{value:h,onValueChange:b,className:"courier-h-full",ref:o,children:(0,Ie.jsx)(Oa,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Pn.length}, fit-content(100%))`},children:p.map(T=>(0,Ie.jsxs)(Gi,{value:T.value,className:"!courier-px-2 courier-w-full courier-flex courier-items-center courier-justify-between courier-h-full courier-border-b-2 courier-border-b-transparent !courier-rounded-none data-[state=active]:courier-bg-transparent data-[state=active]:courier-text-foreground data-[state=active]:courier-border-b-accent-foreground",children:[T.label,T.value===h&&p.length>1&&(0,Ie.jsxs)(rf,{children:[(0,Ie.jsx)(of,{asChild:!0,children:(0,Ie.jsx)("div",{className:"courier-pl-2",children:(0,Ie.jsx)(Wa,{color:"#A3A3A3"})})}),(0,Ie.jsxs)(Bu,{ref:o,children:[(0,Ie.jsx)(Fu,{children:(0,Ie.jsx)(Zb.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,Ie.jsxs)(Vu,{children:[(0,Ie.jsx)(Wu,{asChild:!0,children:(0,Ie.jsx)(Oe,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,Ie.jsx)(Ou,{asChild:!0,children:(0,Ie.jsx)(Oe,{buttonSize:"small",variant:"primary",onClick:()=>x(T.value),children:"Delete"})})]})]})]})]},T.value))})}),v.length>0&&(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(ju,{orientation:"vertical",className:"!courier-h-5"}),(0,Ie.jsxs)(Ys,{children:[(0,Ie.jsx)(Xs,{asChild:!0,children:(0,Ie.jsx)(Oe,{variant:"link",children:"+ Add channel"})}),(0,Ie.jsx)(Ha,{portalProps:{container:o.current},children:v.map(T=>(0,Ie.jsxs)(Ba,{onClick:()=>A(T.value),children:[T.icon,T.label]},T.value))})]})]})]}),(0,Ie.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,Ie.jsx)(ea,{isLoading:!!i,isSaving:!!n,isError:!!s}),!e&&i!==null&&(0,Ie.jsx)(Oe,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:y,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var Gt=require("react");function Na({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[s,l]=(0,Gt.useState)(!1),c=(0,Gt.useRef)(!1),u=(0,Gt.useRef)(null),d=(0,Gt.useRef)(),f=(0,Gt.useRef)(0),m=(0,Gt.useRef)();(0,Gt.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let p=(0,Gt.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(y){console.error("[AutoSave] Error flushing updates:",y)}let P=u.current;if(u.current=null,!!P)try{let y=JSON.stringify(P);if(y===d.current)return;c.current=!0,l(!0),d.current=y,f.current=Date.now(),await e(P)}catch(y){console.error("[AutoSave] Save failed:",y),o==null||o(y)}finally{if(c.current=!1,l(!1),u.current){let y=t;m.current=setTimeout(()=>{m.current=void 0,p()},y)}}},[t,o,e,i]),v=(0,Gt.useRef)(r),h=(0,Gt.useRef)(t),g=(0,Gt.useRef)(p);return(0,Gt.useEffect)(()=>{v.current=r,h.current=t,g.current=p}),{handleAutoSave:(0,Gt.useCallback)(async P=>{if(!v.current)return;let y=JSON.stringify(P);if(u.current=P,y===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let b=h.current;m.current=setTimeout(()=>{m.current=void 0,g.current()},b)},[]),isSaving:s}}a(Na,"useAutoSave");var xt=require("jotai"),We=require("react");var Xo=require("jotai"),Kt=require("react");var hr=require("zod"),qb=hr.z.object({headerStyle:hr.z.enum(["plain","border"]),isUnsubscribe:hr.z.boolean().optional(),isPreferences:hr.z.boolean().optional(),link:hr.z.string().optional(),brandColor:hr.z.string(),textColor:hr.z.string(),subtleColor:hr.z.string(),logo:hr.z.string().optional(),facebookLink:hr.z.string().optional(),linkedinLink:hr.z.string().optional(),instagramLink:hr.z.string().optional(),mediumLink:hr.z.string().optional(),xLink:hr.z.string().optional()}),br={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var Vv=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Us=a(e=>{var t,r,o,n,i,s,l,c,u,d,f,m,p,v;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let h=e.text||"";if((r=e.marks)!=null&&r.length){let C=e.marks.map(Vv).filter(Boolean);h=C.join("")+h+C.reverse().join("")}let g=(o=e.marks)==null?void 0:o.find(C=>C.type==="link");return g&&(h=`[${h}](${(n=g.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
203
- `;case"paragraph":return(((i=e.content)==null?void 0:i.map(Us).join(""))||"")+`
196
+ `}]}),h.elements||(h.elements=[]);let C=[...h.elements.filter(T=>T.type!=="action")];if(p.enableButton){let T={type:"action",content:p.buttonLabel,background_color:p.buttonStyle==="outlined"?"#ffffff":"#000000",color:p.buttonStyle==="outlined"?"#000000":"#ffffff",border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:p.buttonUrl,style:p.buttonStyle==="outlined"?"link":"button"};C.push(T)}if(p.enableSecondaryButton){let T={type:"action",content:p.secondaryButtonLabel,background_color:p.secondaryButtonStyle==="outlined"?"#ffffff":"#000000",color:p.secondaryButtonStyle==="outlined"?"#000000":"#ffffff",border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:p.secondaryButtonUrl,style:p.secondaryButtonStyle==="outlined"?"link":"button"};C.push(T)}let P={...h,elements:C},b=y.elements.findIndex(T=>T.type==="channel"&&T.channel==="inbox"),g=[...y.elements];b!==-1?g[b]=P:g.push(P);let N={...y,elements:g};r(N),o(N)},[r,o]),u=(0,pr.useCallback)(p=>{if(!e)return!1;let{doc:y}=e.state,h=null,v=[];y.descendants((P,b)=>P.type.name==="buttonRow"&&h===null?(h=b,!1):(P.type.name==="button"&&v.push({pos:b,attrs:P.attrs}),!0));let C=a((P,b)=>{let g=y.nodeAt(P);return g?(e.commands.command(({tr:N})=>(N.setNodeMarkup(P,g.type,b),!0)),!0):!1},"applyAttrs");if(h!==null){let P=y.nodeAt(h);if(!P)return!1;let b={...P.attrs,button1Label:p.buttonLabel,button1Link:p.buttonUrl,button1BackgroundColor:p.buttonStyle==="outlined"?"#ffffff":"#000000",button1TextColor:p.buttonStyle==="outlined"?"#000000":"#ffffff",button2Label:p.secondaryButtonLabel,button2Link:p.secondaryButtonUrl,button2BackgroundColor:p.secondaryButtonStyle==="outlined"?"#ffffff":"#000000",button2TextColor:p.secondaryButtonStyle==="outlined"?"#000000":"#ffffff"};return C(h,b)}if(v.length>0){let[P,b]=v,g={...P.attrs,label:p.buttonLabel,link:p.buttonUrl,backgroundColor:p.buttonStyle==="outlined"?"#ffffff":"#000000",textColor:p.buttonStyle==="outlined"?"#000000":"#ffffff"},N=C(P.pos,g),T=!0;if(b){let R={...b.attrs,label:p.secondaryButtonLabel,link:p.secondaryButtonUrl,backgroundColor:p.secondaryButtonStyle==="outlined"?"#ffffff":"#000000",textColor:p.secondaryButtonStyle==="outlined"?"#000000":"#ffffff"};T=C(b.pos,R)}return N&&T}return!1},[e]),d=(0,pr.useCallback)(p=>{if(n.current)return;let y=i.current;if(i.current=p,!y||y.enableButton!==p.enableButton||y.enableSecondaryButton!==p.enableSecondaryButton){c(p);return}u(p)||c(p)},[c,u]),f=Jc("inbox-sidebar",d,500),m=(0,pr.useCallback)(()=>{let p=l.getValues();f(p)},[l,f]);return(0,le.jsx)(et,{...l,children:(0,le.jsxs)("form",{onChange:m,children:[(0,le.jsx)("div",{className:"courier-pb-4",children:(0,le.jsx)(X,{control:l.control,name:"enableButton",render:({field:p})=>(0,le.jsxs)(K,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,le.jsx)(Oo,{className:"!courier-m-0",children:"Enable button"}),(0,le.jsx)(Y,{children:(0,le.jsx)(Ui,{checked:p.value,onCheckedChange:p.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(X,{control:l.control,name:"buttonStyle",render:({field:p})=>(0,le.jsxs)(K,{className:"courier-mb-4",children:[(0,le.jsx)(Y,{children:(0,le.jsxs)(er,{type:"single",value:p.value,onValueChange:y=>{p.onChange(y),m()},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",children:[(0,le.jsx)(tt,{size:"sm",value:"filled",className:"courier-w-full courier-h-7",children:"Filled"}),(0,le.jsx)(tt,{size:"sm",value:"outlined",className:"courier-w-full courier-h-7",children:"Outlined"})]})}),(0,le.jsx)(Q,{})]})}),(0,le.jsx)(X,{control:l.control,name:"buttonUrl",render:({field:p})=>(0,le.jsxs)(K,{className:"courier-mb-6",children:[(0,le.jsx)(Oo,{children:"Action URL"}),(0,le.jsx)(Y,{children:(0,le.jsx)(ye,{placeholder:"https://example.com",...p})}),(0,le.jsx)(Q,{})]})})]}),(0,le.jsx)(be,{className:"courier-mb-6"}),(0,le.jsx)(X,{control:l.control,name:"enableSecondaryButton",render:({field:p})=>(0,le.jsxs)(K,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,le.jsx)(Oo,{className:"!courier-m-0",children:"Enable secondary button"}),(0,le.jsx)(Y,{children:(0,le.jsx)(Ui,{checked:p.value,onCheckedChange:p.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(X,{control:l.control,name:"secondaryButtonStyle",render:({field:p})=>(0,le.jsxs)(K,{className:"courier-mb-4",children:[(0,le.jsx)(Y,{children:(0,le.jsxs)(er,{type:"single",value:p.value,onValueChange:y=>{p.onChange(y),m()},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",children:[(0,le.jsx)(tt,{size:"sm",value:"filled",className:"courier-w-full courier-h-7",children:"Filled"}),(0,le.jsx)(tt,{size:"sm",value:"outlined",className:"courier-w-full courier-h-7",children:"Outlined"})]})}),(0,le.jsx)(Q,{})]})}),(0,le.jsx)(X,{control:l.control,name:"secondaryButtonUrl",render:({field:p})=>(0,le.jsxs)(K,{className:"courier-mb-4",children:[(0,le.jsx)(Oo,{children:"Action URL"}),(0,le.jsx)(Y,{children:(0,le.jsx)(ye,{placeholder:"https://example.com",...p})}),(0,le.jsx)(Q,{})]})})]})]})})},"SideBarComponent"),Gc=(0,pr.memo)(fv);var G5=require("jotai");var mn=require("react/jsx-runtime"),K5=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let s=(0,G5.useAtomValue)(se);return(0,mn.jsx)(Zc,{value:s,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,mn.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,mn.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,mn.jsx)(qc,{...l})}),(0,mn.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,mn.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,mn.jsx)(Gc,{})})})]}),...i})},"InboxLayout");var Y5=require("@tiptap/react"),So=require("jotai"),Ct=require("react");var Ym=require("react/jsx-runtime"),X5=a(({value:e})=>{let{editor:t}=(0,Y5.useCurrentEditor)(),r=(0,So.useSetAtom)(ze),o=(0,So.useAtomValue)(se),n=(0,So.useAtomValue)(ge),i=(0,Ct.useRef)(!1);return(0,Ct.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,Ct.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ct.useEffect)(()=>{t&&(r(t),Dr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ct.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=Q5(o),l=s.type==="channel"&&"elements"in s&&s.elements||Pi;l=l.map(m=>m.type==="meta"&&"title"in m?{type:"text",content:m.title||`
197
+ `,text_style:"h2"}:m);let u=Qe({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=Ce(u),f=Ce(t.getJSON());JSON.stringify(d)!==JSON.stringify(f)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Pi=[{type:"meta",title:""},{type:"text",content:`
198
+ `}],Q5=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="push");return t||(t={type:"channel",channel:"push",elements:Pi}),t},"getOrCreatePushElement"),eb={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},gv=(0,Ct.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,So.useAtomValue)(ge),p=(0,Ct.useRef)(!0),y=(0,Ct.useRef)(!1),h=(0,So.useSetAtom)(ke),[v,C]=(0,So.useAtom)(se),P=(0,So.useSetAtom)(lt),b=(0,So.useAtomValue)(Ut),g=(0,Ct.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,Ct.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let N=(0,Ct.useMemo)(()=>[...Nr({variables:g,setSelectedNode:h,disableVariableAutocomplete:!0})].filter(E=>E!==void 0),[g,h,!0]),T=(0,Ct.useCallback)(({editor:E})=>{if(b)return;if(!v){let L=Ce(E.getJSON()),I=L[0],B="",F=L;I&&I.type==="text"&&"text_style"in I&&I.text_style==="h2"&&"content"in I&&(B=I.content.trim(),F=L.slice(1));let W={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:po(null,"push",B,F).elements}]};C(W),P(W);return}let w=Ce(E.getJSON()),k=w[0],x="",A=w;k&&k.type==="text"&&"text_style"in k&&k.text_style==="h2"&&"content"in k&&(x=k.content.trim(),A=w.slice(1));let M=po(v,"push",x,A),S=St(v,{channel:"push",elements:M.elements});JSON.stringify(v)!==JSON.stringify(S)&&(C(S),P(S))},[v,C,P,b]),R=(0,Ct.useMemo)(()=>{if(m!==!1)return null;let E=c==null?void 0:c.elements.find(x=>x.type==="channel"&&x.channel==="push");!E&&v&&(E=Q5(v));let w=(E==null?void 0:E.type)==="channel"&&"elements"in E&&E.elements||Pi;return w=w.map(x=>x.type==="meta"&&"title"in x?{type:"text",content:x.title||`
199
+ `,text_style:"h2"}:x),Qe({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:w}]})},[c,v,m]);return(0,Ym.jsx)(wr,{theme:e,isLoading:!!(m&&p.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,Ym.jsx)(no,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:l==null?void 0:l({content:R,extensions:N,editable:!o,autofocus:!o,onUpdate:T})})}),Kc=(0,Ct.memo)(gv);var tb=require("@tiptap/react");var fr=require("react/jsx-runtime"),Yc=a(({children:e})=>(0,fr.jsxs)("div",{className:"courier-relative",children:[(0,fr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,fr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,fr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,fr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,fr.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,fr.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,fr.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,fr.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,fr.jsx)(gf,{}),(0,fr.jsx)(hf,{}),(0,fr.jsx)(ff,{})]})]}),(0,fr.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var qr=require("react/jsx-runtime"),Xc=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,qr.jsxs)(Yc,{children:[(0,qr.jsxs)("div",{className:D("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,qr.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,qr.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,qr.jsx)(tb.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:D("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,qr.jsx)(ao,{value:l,defaultValue:Pi}):(0,qr.jsxs)(qr.Fragment,{children:[(0,qr.jsx)(X5,{value:l}),(0,qr.jsx)(Lr,{config:eb})]})})]})},"PushEditor");var rb=require("jotai");var Qc=require("react/jsx-runtime"),ob=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let s=(0,rb.useAtomValue)(se);return(0,Qc.jsx)(Kc,{value:s,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,Qc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Qc.jsx)(Xc,{...l})}),...i})},"PushLayout");var nb=require("@tiptap/react"),Br=require("jotai"),De=require("react");var va=require("react/jsx-runtime"),Ds=[{type:"text",content:`
200
+ `}],ib=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="slack");return t||(t={type:"channel",channel:"slack",elements:Ds}),t},"getOrCreateSlackElement"),ab=a(({value:e})=>{let{editor:t}=(0,nb.useCurrentEditor)(),r=(0,Br.useSetAtom)(ze),o=(0,Br.useAtomValue)(se),n=(0,Br.useAtomValue)(ge),i=(0,Br.useAtomValue)(ke),s=(0,De.useRef)(!1),l=(0,De.useRef)(!1);return(0,De.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,De.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,De.useEffect)(()=>{t&&(r(t),Dr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,De.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,De.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,De.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=ib(o),u=Qe({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=Ce(u),f=Ce(t.getJSON());JSON.stringify(d)!==JSON.stringify(f)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),sb={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"slack-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"slack-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},hv=(0,De.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,Br.useAtomValue)(ge),p=(0,Br.useAtomValue)(Ut),y=(0,Br.useAtomValue)(ze),h=(0,Br.useAtomValue)(vr),[v,C]=(0,Br.useAtom)(ke),[P,b]=(0,Br.useAtom)(se),g=(0,Br.useSetAtom)(lt),N=(0,De.useRef)(!0),T=(0,De.useRef)(!1),R=(0,De.useRef)(h),E=(0,De.useRef)(null),[w,k]=(0,De.useState)({Sidebar:["text","divider","button"],Editor:[]});pa({items:w,setItems:k});let{syncEditorItems:x}=Ic({setItems:k,rafId:E});(0,De.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,De.useEffect)(()=>{R.current=h},[h]),(0,De.useEffect)(()=>{m===!1&&P&&setTimeout(()=>{y&&!y.isDestroyed&&x(y)},300)},[m,P,y,x]);let A=(0,De.useCallback)(()=>!R.current,[]),M=(0,De.useMemo)(()=>[...Nr({variables:r,setSelectedNode:C,shouldHandleClick:A,disableVariableAutocomplete:!0})].filter(I=>I!==void 0),[r,C,A,!0]),S=(0,De.useCallback)(({editor:I})=>{if(!I||p)return;if(!P){let Z={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:Ce(I.getJSON())}]};b(Z),g(Z);return}let B=I.getJSON(),F=Ce(B),U=St(P,{elements:F,channel:"slack"}),W=JSON.stringify(P.elements),O=JSON.stringify(U.elements);W!==O&&(b(U),g(U))},[P,b,g,p]),L=(0,De.useMemo)(()=>{let I=ib(c);return Qe({version:"2022-01-01",elements:[I]},{channel:"slack"})},[c]);return(0,va.jsx)(wr,{theme:e,isLoading:!!(m&&N.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,va.jsx)(no,{hidePublish:t,channels:n,routing:i}),ref:d,...u,children:(0,va.jsx)(va.Fragment,{children:l==null?void 0:l({content:L,extensions:M,editable:!o,autofocus:!o,onUpdate:S,items:w,selectedNode:v,slackEditor:y})})})}),eu=(0,De.memo)(hv);var ub=require("@tiptap/react");var Ge=require("react/jsx-runtime"),bv=a(()=>(0,Ge.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Ge.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,Ge.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,Ge.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"})]}),"TextSkeleton"),yv=a(()=>(0,Ge.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-lg",children:(0,Ge.jsx)($a,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),lb=a(()=>(0,Ge.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Ge.jsx)(yv,{}),(0,Ge.jsx)(bv,{})]}),"InteractionSkeleton"),cb=a(({children:e,className:t})=>(0,Ge.jsxs)("div",{className:D("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ge.jsx)(lb,{}),(0,Ge.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ge.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Ge.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Ge.jsx)(_a,{color:"#FFFFFF"})})}),(0,Ge.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ge.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Ge.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900",children:"Circle"}),(0,Ge.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 courier-text-gray-700",children:"APP"}),(0,Ge.jsx)("span",{className:"courier-text-xs courier-text-gray-500",children:"Now"})]}),(0,Ge.jsx)("div",{className:"courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Ge.jsx)(lb,{})]}),"SlackFrame");var tu=require("react");var Io=require("react/jsx-runtime"),ru=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,tu.useRef)(null);return(0,tu.useEffect)(()=>{let l=s.current;if(!(!l||i))return Ur({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Io.jsx)(cb,{children:(0,Io.jsx)("div",{ref:s,children:(0,Io.jsx)(ub.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:D("courier-slack-editor")},immediatelyRender:!1,children:i?(0,Io.jsx)(ao,{value:e,defaultValue:Ds}):(0,Io.jsxs)(Io.Fragment,{children:[(0,Io.jsx)(ab,{value:e}),(0,Io.jsx)(Lr,{config:sb})]})})})}):null},"SlackEditor");var gb=require("jotai");var db=require("lucide-react");var nr=require("react/jsx-runtime"),ou=a(({items:e,label:t,editor:r})=>(0,nr.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,nr.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,nr.jsxs)(nr.Fragment,{children:[(0,nr.jsx)("p",{children:t}),(0,nr.jsx)(be,{className:"courier-my-4"})]}),(0,nr.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,nr.jsx)(ba,{id:o.toString(),editor:r,children:(0,nr.jsxs)("div",{className:D("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,nr.jsx)(db.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,nr.jsx)(An,{draggable:!0}),o==="divider"&&(0,nr.jsx)(Mn,{draggable:!0}),o==="button"&&(0,nr.jsx)(kn,{draggable:!0})]})},o))})]})}),"SlackSideBar");var mb=require("@hookform/resolvers/zod"),pb=require("react-hook-form");var Lo=require("react/jsx-runtime"),fb=a(({element:e,editor:t})=>{var s,l;let r=(0,pb.useForm)({resolver:(0,mb.zodResolver)(Pl),defaultValues:{..._e,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=zt({editor:t,element:e,form:r,nodeType:"button"}),n=((l=(s=t==null?void 0:t.extensionManager.extensions.find(c=>c.name==="variableSuggestion"))==null?void 0:s.options)==null?void 0:l.variables)||{},i=zr(n);return e?(0,Lo.jsxs)(et,{...r,children:[(0,Lo.jsx)(rr,{type:"button"}),(0,Lo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Lo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,Lo.jsx)(X,{control:r.control,name:"link",render:({field:c})=>(0,Lo.jsxs)(K,{children:[(0,Lo.jsx)(Y,{children:(0,Lo.jsx)(Pr,{as:"Textarea",...c,variables:i,onChange:u=>{c.onChange(u),o({...r.getValues(),link:u.target.value})}})}),(0,Lo.jsx)(Q,{})]})})]})]}):null},"SlackButtonForm");var Xm=require("react/jsx-runtime"),nu=a(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,Xm.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,Xm.jsx)(fb,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var Qm=require("react");var Hr=require("react/jsx-runtime"),vv=(0,Qm.forwardRef)(({children:e,className:t,...r},o)=>(0,Hr.jsx)("div",{className:D("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Cv=(0,Qm.forwardRef)(({children:e,...t},r)=>(0,Hr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),hb=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,gb.useAtomValue)(se);return(0,Hr.jsx)(eu,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:s=>{var l;return(0,Hr.jsxs)(Vn,{children:[(0,Hr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Hr.jsx)(vv,{children:(0,Hr.jsx)(Cv,{children:(0,Hr.jsx)(ru,{...s})})})}),(0,Hr.jsx)(On,{children:(0,Hr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Hr.jsx)(nu,{element:s.selectedNode,editor:s.slackEditor,defaultElement:(0,Hr.jsx)(ou,{items:s.items.Sidebar,label:"Blocks library",editor:(l=s.slackEditor)!=null?l:void 0})})})})]})}})},"SlackLayout");var bb=require("@tiptap/react"),Ro=require("jotai"),je=require("react"),yb=require("sms-segments-calculator");var iu=require("react/jsx-runtime"),pn=[{type:"text",content:`
201
+ `}],vb=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="sms");return t||(t={type:"channel",channel:"sms",elements:pn}),t},"getOrCreateSMSElement"),Cb=a(({value:e})=>{var c;let{editor:t}=(0,bb.useCurrentEditor)(),r=(0,Ro.useSetAtom)(ze),o=(0,Ro.useAtomValue)(se),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,je.useMemo)(()=>new yb.SegmentedMessage(n),[n]),s=(0,Ro.useAtomValue)(ge),l=(0,je.useRef)(!1);return(0,je.useEffect)(()=>{s&&(l.current=!1)},[s]),(0,je.useEffect)(()=>{!t||s!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,s]),(0,je.useEffect)(()=>{t&&(r(t),Dr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,je.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=vb(o),f={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||pn},m=Qe({version:"2022-01-01",elements:[f]}),p=Ce(m),y=Ce(t.getJSON());JSON.stringify(p)!==JSON.stringify(y)&&setTimeout(()=>{t.isFocused||t.commands.setContent(m)},1)},[t,o]),(0,iu.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),xb={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},xv=(0,je.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,render:s,headerRenderer:l,value:c,...u},d)=>{let m=(0,Ro.useAtomValue)(ge),p=(0,je.useRef)(!0),y=(0,je.useRef)(!1),h=(0,Ro.useSetAtom)(ke),[v,C]=(0,Ro.useAtom)(se),P=(0,Ro.useSetAtom)(lt),b=(0,Ro.useAtomValue)(Ut),g=(0,je.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,je.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let N=(0,je.useMemo)(()=>[...Nr({variables:g,setSelectedNode:h,disableVariableAutocomplete:!0})].filter(x=>x!==void 0),[g,h,!0]),T=(0,je.useRef)(!1),R=(0,je.useCallback)(({editor:x})=>{if(b)return;if(!v){let L=Ce(x.getJSON()),I=Us(L),B={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:I.length>0?I:pn}]};T.current=!0,C(B),P(B);return}let A=Ce(x.getJSON()),M=Us(A),S=St(v,{channel:"sms",elements:M.length>0?M:pn});JSON.stringify(v)!==JSON.stringify(S)&&(T.current=!0,C(S),P(S))},[v,C,P,b]),[E,w]=(0,je.useState)(null),k=(0,je.useCallback)(x=>{if(!x)return null;let A=x==null?void 0:x.elements.find(L=>L.type==="channel"&&L.channel==="sms");A||(A=vb(x));let S={type:"channel",channel:"sms",elements:(A==null?void 0:A.type)==="channel"&&"elements"in A&&A.elements||pn};return Qe({version:"2022-01-01",elements:[S]})},[]);return(0,je.useEffect)(()=>{if(m!==!1)return;if(T.current){T.current=!1;return}let x=c!=null?c:v,A=k(x);A&&w(A)},[c,v,k,m]),(0,iu.jsx)(wr,{theme:e,isLoading:!!(m&&p.current),Header:l?l({hidePublish:t,channels:n,routing:i}):(0,iu.jsx)(no,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:s==null?void 0:s({content:E,extensions:N,editable:!o,autofocus:!o,onUpdate:R})})}),au=(0,je.memo)(xv);var Tb=require("@tiptap/react");var Do=require("react/jsx-runtime"),su=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,Do.jsx)(Yc,{children:(0,Do.jsx)("div",{className:D("courier-sms-editor",i),children:(0,Do.jsx)(Tb.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,Do.jsx)(ao,{value:l,defaultValue:pn}):(0,Do.jsxs)(Do.Fragment,{children:[(0,Do.jsx)(Cb,{value:l}),(0,Do.jsx)(Lr,{config:xb})]})})})})},"SMSEditor");var wb=require("jotai");var lu=require("react/jsx-runtime"),Eb=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,dataMode:i,...s})=>{let l=(0,wb.useAtomValue)(se);return(0,lu.jsx)(au,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,dataMode:i,render:c=>(0,lu.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,lu.jsx)(su,{...c})}),...s})},"SMSLayout");var Pb=require("@tiptap/react"),Fr=require("jotai"),Ne=require("react");var Ca=require("react/jsx-runtime"),Bs=[{type:"text",content:`
202
+ `}],kb=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="msteams");return t||(t={type:"channel",channel:"msteams",elements:Bs}),t},"getOrCreateMSTeamsElement"),Mb=a(({value:e})=>{let{editor:t}=(0,Pb.useCurrentEditor)(),r=(0,Fr.useSetAtom)(ze),o=(0,Fr.useAtomValue)(se),n=(0,Fr.useAtomValue)(ge),i=(0,Fr.useAtomValue)(ke),s=(0,Ne.useRef)(!1),l=(0,Ne.useRef)(!1);return(0,Ne.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Ne.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ne.useEffect)(()=>{t&&(r(t),Dr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ne.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ne.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ne.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=kb(o),u=Qe({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=Ce(u),f=Ce(t.getJSON());JSON.stringify(d)!==JSON.stringify(f)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),Ab={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"msteams-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"msteams-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},Tv=(0,Ne.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:s,render:l,value:c,...u},d)=>{let m=(0,Fr.useAtomValue)(ge),p=(0,Fr.useAtomValue)(Ut),y=(0,Fr.useAtomValue)(ze),h=(0,Fr.useAtomValue)(vr),[v,C]=(0,Fr.useAtom)(ke),[P,b]=(0,Fr.useAtom)(se),g=(0,Fr.useSetAtom)(lt),N=(0,Ne.useRef)(!0),T=(0,Ne.useRef)(!1),R=(0,Ne.useRef)(h),[E,w]=(0,Ne.useState)({Sidebar:["text","divider"],Editor:[]}),k=(0,Ne.useRef)(null);pa({items:E,setItems:w});let x=(0,Ne.useCallback)(I=>{k.current&&cancelAnimationFrame(k.current),setTimeout(()=>{k.current=requestAnimationFrame(()=>{try{let B=I==null?void 0:I.view.dom;if(!B){console.warn("syncEditorItems: Editor DOM element not found");return}let F=B.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),U=[];F.forEach(W=>{let O=W.dataset.id;O&&U.push(O)}),w(W=>({Editor:U,Sidebar:W.Sidebar}))}catch(B){console.error("Error syncing editor items:",B),w(F=>({...F}))}})},50)},[]);(0,Ne.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,Ne.useEffect)(()=>{R.current=h},[h]),(0,Ne.useEffect)(()=>{let I=a(()=>{y&&x(y)},"updateItems");y==null||y.on("update",I),y==null||y.on("selectionUpdate",I),y==null||y.on("create",I),y==null||y.on("transaction",I),y&&!y.isDestroyed&&I();let B=a(F=>{I()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",B),()=>{y==null||y.off("update",I),y==null||y.off("selectionUpdate",I),y==null||y.off("create",I),y==null||y.off("transaction",I),document.removeEventListener("node-duplicated",B),k.current&&cancelAnimationFrame(k.current)}},[y,x]),(0,Ne.useEffect)(()=>{m===!1&&P&&setTimeout(()=>{y&&!y.isDestroyed&&x(y)},300)},[m,P,y,x]);let A=(0,Ne.useCallback)(()=>!R.current,[]),M=(0,Ne.useMemo)(()=>[...Nr({variables:r,setSelectedNode:C,shouldHandleClick:A,disableVariableAutocomplete:!0})].filter(I=>I!==void 0),[r,C,A,!0]),S=(0,Ne.useCallback)(({editor:I})=>{if(!I||p)return;if(!P){let Z={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:Ce(I.getJSON())}]};b(Z),g(Z);return}let B=I.getJSON(),F=Ce(B),U=St(P,{elements:F,channel:"msteams"}),W=JSON.stringify(P.elements),O=JSON.stringify(U.elements);W!==O&&(b(U),g(U))},[P,b,g,p]),L=(0,Ne.useMemo)(()=>{let I=kb(c);return Qe({version:"2022-01-01",elements:[I]},{channel:"msteams"})},[c]);return(0,Ca.jsx)(wr,{theme:e,isLoading:!!(m&&N.current),Header:s?s({hidePublish:t,channels:n,routing:i}):(0,Ca.jsx)(no,{hidePublish:t,channels:n,routing:i}),ref:d,...u,children:(0,Ca.jsx)(Ca.Fragment,{children:l==null?void 0:l({content:L,extensions:M,editable:!o,autofocus:!o,onUpdate:S,items:E,selectedNode:v,msteamsEditor:y})})})}),cu=(0,Ne.memo)(Tv);var Sb=require("@tiptap/react");var Ye=require("react/jsx-runtime"),wv=a(()=>(0,Ye.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-full",children:(0,Ye.jsx)($a,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),Ev=a(()=>(0,Ye.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Ye.jsx)(wv,{}),(0,Ye.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Ye.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] courier-rounded-[12px]"}),(0,Ye.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),Pv=a(()=>(0,Ye.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Ye.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Ye.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),Nb=a(({children:e,className:t})=>(0,Ye.jsxs)("div",{className:D("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ye.jsx)(Ev,{}),(0,Ye.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ye.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Ye.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Ye.jsx)(_a,{color:"#FFFFFF"})})}),(0,Ye.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ye.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Ye.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3]",children:"Circle"})}),(0,Ye.jsx)("div",{className:"courier-bg-[#F5F5F5] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,Ye.jsx)(Pv,{})]}),"MSTeamsFrame");var uu=require("react");var Bo=require("react/jsx-runtime"),du=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,uu.useRef)(null);return(0,uu.useEffect)(()=>{let l=s.current;if(!(!l||i))return Ur({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Bo.jsx)(Nb,{children:(0,Bo.jsx)("div",{ref:s,children:(0,Bo.jsx)(Sb.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:D("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,Bo.jsx)(ao,{value:e,defaultValue:Bs}):(0,Bo.jsxs)(Bo.Fragment,{children:[(0,Bo.jsx)(Mb,{value:e}),(0,Bo.jsx)(Lr,{config:Ab})]})})})}):null},"MSTeamsEditor");var Lb=require("jotai");var Ib=require("lucide-react");var ir=require("react/jsx-runtime"),mu=a(({items:e,label:t,editor:r})=>(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,ir.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,ir.jsxs)(ir.Fragment,{children:[(0,ir.jsx)("p",{children:t}),(0,ir.jsx)(be,{className:"courier-my-4"})]}),(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,ir.jsx)(ba,{id:o.toString(),editor:r,children:(0,ir.jsxs)("div",{className:D("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,ir.jsx)(Ib.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,ir.jsx)(An,{draggable:!0}),o==="divider"&&(0,ir.jsx)(Mn,{draggable:!0}),o==="button"&&(0,ir.jsx)(kn,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");var ep=require("react");var Jr=require("react/jsx-runtime"),kv=(0,ep.forwardRef)(({children:e,className:t,...r},o)=>(0,Jr.jsx)("div",{className:D("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Mv=(0,ep.forwardRef)(({children:e,...t},r)=>(0,Jr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),Rb=a(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,Lb.useAtomValue)(se);return(0,Jr.jsx)(cu,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:s=>{var l;return(0,Jr.jsxs)(Vn,{children:[(0,Jr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Jr.jsx)(kv,{children:(0,Jr.jsx)(Mv,{children:(0,Jr.jsx)(du,{...s})})})}),(0,Jr.jsx)(On,{children:(0,Jr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Jr.jsx)(mu,{items:s.items.Sidebar,label:"Blocks library",editor:(l=s.msteamsEditor)!=null?l:void 0})})})]})}})},"MSTeamsLayout");var Db={sms:{elements:pn},push:{elements:Pi},inbox:{elements:Rs},slack:{elements:Ds},email:{elements:As},msteams:{elements:Bs}},Bb=a(e=>{var t;return(t=Db[e])!=null?t:Db.email},"getChannelDefaults"),Av=a((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["email"]},"resolveChannels"),pu=a(({channels:e=["email"],routing:t})=>{let[r,o]=(0,Vr.useState)([]),n=(0,fn.useAtomValue)(se),i=(0,fn.useSetAtom)(se),s=(0,fn.useSetAtom)(lt),[l,c]=(0,fn.useAtom)(xn),u=(0,fn.useSetAtom)(ke),d=(0,fn.useAtomValue)(ge),f=Av(t,e),m=(0,Vr.useRef)(f);m.current=f,(0,Vr.useEffect)(()=>{if(d||n!=null&&n.elements)return;let P=m.current.map(b=>Cn.find(g=>g.value===b)).filter(b=>!!b);o(P),P.length>0&&!l&&c(P[0].value)},[n,d,c,l]),(0,Vr.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let C=m.current,P=n.elements.filter(g=>g.type==="channel").map(g=>g.channel).filter(g=>C.includes(g)),b=C.filter(g=>P.includes(g)).map(g=>Cn.find(N=>N.value===g)).filter(g=>!!g);o(b)},[n,d]),(0,Vr.useEffect)(()=>{var b;if(d||r.length===0)return;let C=r.some(g=>g.value===l),P=(b=n==null?void 0:n.elements)==null?void 0:b.some(g=>g.type==="channel"&&g.channel===l);!C&&!P&&c(r[0].value)},[r,l,c,d,n]);let p=(0,Vr.useMemo)(()=>(f==null?void 0:f.filter(C=>!r.some(P=>P.value===C)).map(C=>Cn.find(P=>P.value===C)).filter(C=>!!C))||[],[r,f]),y=(0,Vr.useCallback)(C=>{let P=[],b,{elements:g,raw:N}=Bb(C);if(P=g,b=N,!n){let E=[];for(let x of r){let{elements:A,raw:M}=Bb(x.value),S={type:"channel",channel:x.value,elements:A};M&&(S.raw=M),E.push(S)}let w={type:"channel",channel:C,elements:P};b&&(w.raw=b),E.push(w);let k={version:"2022-01-01",elements:E};i(k),s(k),c(C);return}let R=St(n,{elements:P,channel:b?{channel:C,raw:b}:C});i(R),s(R),c(C)},[n,i,s,c,r]),h=(0,Vr.useCallback)(C=>{if(!n)return;let P=n.elements.filter(N=>N.type==="channel"?N.channel!==C:!0),b={...n,elements:P};i(b),s(b),u(null);let g=r.filter(N=>N.value!==C);l===C&&g.length>0&&c(g[0].value)},[n,i,s,r,l,c,u]),v=(0,Vr.useMemo)(()=>[...r,...p],[r,p]);return{enabledChannels:r,disabledChannels:p,channel:l,channelOptions:v,setChannel:c,addChannel:y,removeChannel:h}},"useChannels");var Se=require("react/jsx-runtime"),no=a(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,Ko.useRef)(null),n=(0,gn.useAtomValue)(Ot),i=(0,gn.useAtomValue)(ge),s=(0,gn.useAtomValue)(ae),{publishTemplate:l,isTemplatePublishing:c}=Di(),[u,d]=(0,gn.useAtom)(Si),f=(0,gn.useSetAtom)(Vo),m=(0,gn.useAtomValue)(Vo),{enabledChannels:p,disabledChannels:y,channel:h,setChannel:v,addChannel:C,removeChannel:P}=pu({channels:t,routing:r});(0,Ko.useEffect)(()=>{n===!0&&d(null)},[n,d]);let b=(0,Ko.useCallback)(()=>{m&&f(!1),l()},[l,m,f]),g=(0,Ko.useCallback)(E=>{m&&f(!1),v(E)},[m,f,v]),N=(0,Ko.useCallback)(E=>{m&&f(!1),C(E)},[m,f,C]),T=(0,Ko.useCallback)(E=>{m&&f(!1),P(E)},[m,f,P]),R=(0,Ko.useCallback)(()=>{m&&f(!1)},[m,f]);return(0,Se.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:R,children:[(0,Se.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,Se.jsx)(Xs,{value:h,onValueChange:g,className:"courier-h-full",ref:o,children:(0,Se.jsx)(La,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Cn.length}, fit-content(100%))`},children:p.map(E=>(0,Se.jsxs)(zi,{value:E.value,className:"!courier-px-2 courier-w-full courier-flex courier-items-center courier-justify-between courier-h-full courier-border-b-2 courier-border-b-transparent !courier-rounded-none data-[state=active]:courier-bg-transparent data-[state=active]:courier-text-foreground data-[state=active]:courier-border-b-accent-foreground",children:[E.label,E.value===h&&p.length>1&&(0,Se.jsxs)($p,{children:[(0,Se.jsx)(jp,{asChild:!0,children:(0,Se.jsx)("div",{className:"courier-pl-2",children:(0,Se.jsx)(Ra,{color:"#A3A3A3"})})}),(0,Se.jsxs)(Iu,{ref:o,children:[(0,Se.jsx)(Lu,{children:(0,Se.jsx)(Hb.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,Se.jsxs)(Ru,{children:[(0,Se.jsx)(Bu,{asChild:!0,children:(0,Se.jsx)(Ve,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,Se.jsx)(Du,{asChild:!0,children:(0,Se.jsx)(Ve,{buttonSize:"small",variant:"primary",onClick:()=>T(E.value),children:"Delete"})})]})]})]})]},E.value))})}),y.length>0&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(Wu,{orientation:"vertical",className:"!courier-h-5"}),(0,Se.jsxs)(qs,{children:[(0,Se.jsx)(Js,{asChild:!0,children:(0,Se.jsx)(Ve,{variant:"link",children:"+ Add channel"})}),(0,Se.jsx)(Aa,{portalProps:{container:o.current},children:y.map(E=>(0,Se.jsxs)(Na,{onClick:()=>N(E.value),children:[E.icon,E.label]},E.value))})]})]})]}),(0,Se.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,Se.jsx)(qi,{isLoading:!!i,isSaving:!!n,isError:!!s}),!e&&i!==null&&(0,Se.jsx)(Ve,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:b,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var Gt=require("react");function xa({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[s,l]=(0,Gt.useState)(!1),c=(0,Gt.useRef)(!1),u=(0,Gt.useRef)(null),d=(0,Gt.useRef)(),f=(0,Gt.useRef)(0),m=(0,Gt.useRef)();(0,Gt.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let p=(0,Gt.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(b){console.error("[AutoSave] Error flushing updates:",b)}let P=u.current;if(u.current=null,!!P)try{let b=JSON.stringify(P);if(b===d.current)return;c.current=!0,l(!0),d.current=b,f.current=Date.now(),await e(P)}catch(b){console.error("[AutoSave] Save failed:",b),o==null||o(b)}finally{if(c.current=!1,l(!1),u.current){let b=t;m.current=setTimeout(()=>{m.current=void 0,p()},b)}}},[t,o,e,i]),y=(0,Gt.useRef)(r),h=(0,Gt.useRef)(t),v=(0,Gt.useRef)(p);return(0,Gt.useEffect)(()=>{y.current=r,h.current=t,v.current=p}),{handleAutoSave:(0,Gt.useCallback)(async P=>{if(!y.current)return;let b=JSON.stringify(P);if(u.current=P,b===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let g=h.current;m.current=setTimeout(()=>{m.current=void 0,v.current()},g)},[]),isSaving:s}}a(xa,"useAutoSave");var xt=require("jotai"),Oe=require("react");var Yo=require("jotai"),Kt=require("react");var gr=require("zod"),Fb=gr.z.object({headerStyle:gr.z.enum(["plain","border"]),isUnsubscribe:gr.z.boolean().optional(),isPreferences:gr.z.boolean().optional(),link:gr.z.string().optional(),brandColor:gr.z.string(),textColor:gr.z.string(),subtleColor:gr.z.string(),logo:gr.z.string().optional(),facebookLink:gr.z.string().optional(),linkedinLink:gr.z.string().optional(),instagramLink:gr.z.string().optional(),mediumLink:gr.z.string().optional(),xLink:gr.z.string().optional()}),hr={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var Nv=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Hs=a(e=>{var t,r,o,n,i,s,l,c,u,d,f,m,p,y;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let h=e.text||"";if((r=e.marks)!=null&&r.length){let C=e.marks.map(Nv).filter(Boolean);h=C.join("")+h+C.reverse().join("")}let v=(o=e.marks)==null?void 0:o.find(C=>C.type==="link");return v&&(h=`[${h}](${(n=v.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
203
+ `;case"paragraph":return(((i=e.content)==null?void 0:i.map(Hs).join(""))||"")+`
204
204
 
205
- `;case"heading":{let h=((s=e.attrs)==null?void 0:s.level)||1,g="#".repeat(h)+" ",C=((l=e.content)==null?void 0:l.map(Us).join(""))||"";return g+C+`
205
+ `;case"heading":{let h=((s=e.attrs)==null?void 0:s.level)||1,v="#".repeat(h)+" ",C=((l=e.content)==null?void 0:l.map(Hs).join(""))||"";return v+C+`
206
206
 
207
- `}case"blockquote":return(((c=e.content)==null?void 0:c.map(Us).join(""))||"").split(`
208
- `).map(g=>`> ${g}`).join(`
207
+ `}case"blockquote":return(((c=e.content)==null?void 0:c.map(Hs).join(""))||"").split(`
208
+ `).map(v=>`> ${v}`).join(`
209
209
  `)+`
210
210
 
211
- `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",g=((d=e.attrs)==null?void 0:d.sourcePath)||"",C=(f=e.attrs)==null?void 0:f.link,P=`![${h}](${g})`;return C?`[${P}](${C})
211
+ `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",v=((d=e.attrs)==null?void 0:d.sourcePath)||"",C=(f=e.attrs)==null?void 0:f.link,P=`![${h}](${v})`;return C?`[${P}](${C})
212
212
 
213
213
  `:P+`
214
214
 
215
215
  `}case"divider":return`---
216
216
 
217
- `;case"button":{let h=((m=e.attrs)==null?void 0:m.label)||"",g=((p=e.attrs)==null?void 0:p.link)||"#";return`[${h}](${g})
217
+ `;case"button":{let h=((m=e.attrs)==null?void 0:m.label)||"",v=((p=e.attrs)==null?void 0:p.link)||"#";return`[${h}](${v})
218
218
 
219
- `}default:return((v=e.content)==null?void 0:v.map(Us).join(""))||""}},"convertNodeToMarkdown");function yu(e){return e.content?e.content.map(Us).join("").trim():""}a(yu,"convertTiptapToMarkdown");var po=require("jotai"),xn=require("react");var Jb=require("react"),Kb=require("react/jsx-runtime"),Gb=(0,Jb.forwardRef)(({children:e},t)=>(0,Kb.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var vu=a((e,t)=>new Promise(r=>{let o=new FileReader;o.onload=n=>{var s;let i=new Image;i.onload=()=>{var f;let l,c;i.width>i.height?(l=Math.min(t,i.width),c=Math.round(i.height/i.width*l)):(c=Math.min(t,i.height),l=Math.round(i.width/i.height*c));let u=document.createElement("canvas");u.width=l,u.height=c;let d=u.getContext("2d");if(d){d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(i,0,0,l,c);let m=.8,p=u.toDataURL(e.type||"image/jpeg",m),v=0,h=5;for(;p.length>512e3&&v<h;)v++,m-=.1,m<.3&&(m=.3),p=u.toDataURL(e.type||"image/jpeg",m);r({dataUrl:p,width:l,height:c})}else r({dataUrl:(f=n.target)==null?void 0:f.result,width:i.width,height:i.height})},i.src=(s=n.target)==null?void 0:s.result},o.readAsDataURL(e)}),"resizeImage");var Yr=require("react");var Aa=require("react/jsx-runtime"),Ov=["image/png","image/jpeg","image/gif","image/webp"],Yb=a(({onFileSelect:e})=>{let[t,r]=(0,Yr.useState)(!1),o=(0,Yr.useRef)(null),n=(0,Yr.useCallback)(m=>Ov.includes(m),[]),i=(0,Yr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&(r(!0),m.dataTransfer.dropEffect="copy")},[n]),s=(0,Yr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=(0,Yr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Yr.useCallback)(async m=>{try{let{dataUrl:p}=await vu(m,800);e==null||e(p),o.current&&(o.current.value="")}catch(p){console.error("Error processing image:",p),o.current&&(o.current.value="")}},[e]),u=(0,Yr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let v=Array.from(m.dataTransfer.files).find(h=>n(h.type));v&&c(v)},[c,n]),d=(0,Yr.useCallback)(m=>{var v;let p=(v=m.target.files)==null?void 0:v[0];p&&c(p)},[c]),f=(0,Yr.useCallback)(m=>{var p;m.preventDefault(),m.stopPropagation(),(p=o.current)==null||p.click()},[]);return(0,Aa.jsxs)("div",{className:R("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:s,onDrop:u,style:{pointerEvents:"all"},children:[(0,Aa.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Aa.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:f,type:"button",children:"Browse"}),(0,Aa.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var Qb=require("@hookform/resolvers/zod"),Sa=require("jotai"),e2=require("lucide-react"),mo=require("react"),t2=require("react-hook-form");var z=require("react/jsx-runtime"),Xb=a(({isActive:e,onClick:t,value:r})=>(0,z.jsx)("div",{className:R("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,z.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,z.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),Wv=a(()=>{let[e,t]=(0,Sa.useAtom)(_o),r=(0,Sa.useSetAtom)(Co),o=(0,Sa.useAtomValue)(Oi),n=(0,mo.useRef)(null),i=(0,t2.useForm)({resolver:(0,Qb.zodResolver)(qb),defaultValues:{...br,...e},mode:"onChange"});(0,mo.useEffect)(()=>{e&&i.reset(e)},[e,i]);let s=(0,mo.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,mo.useCallback)(d=>{var f;if(o){if(d){let p={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(p).run()}else{let p=((f=o.getJSON().content)==null?void 0:f.filter(v=>{var g;return v.type!=="paragraph"?!0:!((g=v.content)==null?void 0:g.some(C=>{var P;return C.type==="text"&&((P=C.marks)==null?void 0:P.some(y=>{var b;return y.type==="link"&&((b=y.attrs)==null?void 0:b.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).run()}r(yu(o.getJSON()))}},[o,r]),c=(0,mo.useMemo)(()=>{var d,f;return((f=(d=o==null?void 0:o.extensionManager.extensions.find(m=>m.name==="variableSuggestion"))==null?void 0:d.options)==null?void 0:f.variables)||{}},[o]),u=(0,mo.useMemo)(()=>$r(c),[c]);return(0,z.jsx)(et,{...i,children:(0,z.jsx)("form",{onChange:()=>s(),children:(0,z.jsxs)("div",{className:"courier-pb-6",children:[(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,z.jsx)(J,{control:i.control,name:"headerStyle",render:({field:d})=>(0,z.jsxs)(Z,{className:"courier-mb-4",children:[(0,z.jsx)(q,{children:(0,z.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,z.jsx)(Xb,{isActive:d.value==="plain",onClick:()=>{d.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,z.jsx)(Xb,{isActive:d.value==="border",onClick:()=>{d.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(ye,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,z.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,z.jsx)(Oe,{onClick:()=>{let d=i.getValues();d.logo="",i.reset(d),t({...d}),n.current&&(n.current.value=""),s()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,z.jsxs)(Oe,{onClick:d=>{d.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,z.jsx)(e2.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,z.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async d=>{var m;let f=(m=d.target.files)==null?void 0:m[0];if(f)try{let{dataUrl:p}=await vu(f,800),v=i.getValues();v.logo=p,i.reset(v),t({...v})}catch(p){console.error("Error processing image:",p)}n.current&&(n.current.value="")}})]}),(0,z.jsx)(J,{control:i.control,name:"link",render:({field:d})=>(0,z.jsxs)(Z,{className:"courier-mb-3",children:[(0,z.jsx)(q,{children:(0,z.jsx)(kr,{as:"Textarea",placeholder:"Link",...d,variables:u,onChange:f=>{d.onChange(f),s()}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(ye,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,z.jsx)(J,{control:i.control,name:"brandColor",render:({field:d})=>(0,z.jsxs)(Z,{className:"courier-mb-4",children:[(0,z.jsx)(q,{children:(0,z.jsx)(lt,{...d,defaultValue:d.value,onChange:f=>{d.onChange(f),s()}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(ye,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,z.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,z.jsx)(J,{control:i.control,name:"facebookLink",render:({field:d})=>(0,z.jsxs)(Z,{children:[(0,z.jsx)(q,{children:(0,z.jsx)(pe,{startAdornment:(0,z.jsx)(za,{}),placeholder:"facebook.com/username",...d,autoFocus:!0})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(J,{control:i.control,name:"linkedinLink",render:({field:d})=>(0,z.jsxs)(Z,{children:[(0,z.jsx)(q,{children:(0,z.jsx)(pe,{startAdornment:(0,z.jsx)(ja,{}),placeholder:"linkedin.com/username",...d})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(J,{control:i.control,name:"instagramLink",render:({field:d})=>(0,z.jsxs)(Z,{children:[(0,z.jsx)(q,{children:(0,z.jsx)(pe,{startAdornment:(0,z.jsx)($a,{}),placeholder:"instagram.com/username",...d})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(J,{control:i.control,name:"mediumLink",render:({field:d})=>(0,z.jsxs)(Z,{children:[(0,z.jsx)(q,{children:(0,z.jsx)(pe,{startAdornment:(0,z.jsx)(Za,{}),placeholder:"medium.com/username",...d})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(J,{control:i.control,name:"xLink",render:({field:d})=>(0,z.jsxs)(Z,{children:[(0,z.jsx)(q,{children:(0,z.jsx)(pe,{startAdornment:(0,z.jsx)(Ka,{}),placeholder:"x.com/username",...d})}),(0,z.jsx)(K,{})]})})]}),(0,z.jsx)(ye,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,z.jsx)(J,{control:i.control,name:"isPreferences",render:({field:d})=>(0,z.jsxs)(Z,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,z.jsx)(q,{children:(0,z.jsx)(Ji,{checked:d.value,onCheckedChange:f=>{i.setValue("isPreferences",f),d.onChange(f),l(f);let m={...i.getValues(),isPreferences:f};t(m)}})}),(0,z.jsx)(Uo,{className:"!courier-m-0",children:"Manage Preferences"}),(0,z.jsx)(K,{})]})})]})})})},"SideBarComponent"),r2=(0,mo.memo)(Wv);var ze=require("react/jsx-runtime"),Uv=(0,xn.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var b,A,x,I,T,k,w,E;let n=(0,po.useSetAtom)(ta),{publishBrand:i}=Wi(),s=(0,po.useAtomValue)(Tt),l=(0,po.useAtomValue)(cr),c=(0,po.useAtomValue)(Ot),u=(0,po.useAtomValue)(be),d=(0,po.useAtomValue)(ae),f=(0,po.useAtomValue)(Oi),[m,p]=(0,po.useAtom)(_o),[v,h]=(0,po.useAtom)(Co),g=(0,xn.useCallback)(()=>{i()},[i]),C=(0,xn.useCallback)(({editor:N})=>{h(yu(N.getJSON()))},[h]),P=(0,xn.useCallback)(N=>{p(M=>M?{...M,logo:N}:{...br,logo:N})},[p]),y=(0,xn.useCallback)(()=>{n("template")},[n]);return(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,ze.jsxs)(Gb,{children:[(0,ze.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,ze.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&(0,ze.jsx)(ea,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&(0,ze.jsx)(Oe,{variant:"outline",buttonSize:"small",onClick:y,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&(0,ze.jsx)(Oe,{variant:"primary",buttonSize:"small",disabled:!((A=(b=s==null?void 0:s.data)==null?void 0:b.tenant)!=null&&A.brand)||l===!0||c!==!1,onClick:g,children:l?"Publishing...":"Publish changes"})]})]})}),(0,ze.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,ze.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,ze.jsxs)("div",{className:"courier-editor-container",ref:o,children:[(0,ze.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,ze.jsxs)("div",{className:R("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(m==null?void 0:m.headerStyle)==="border"&&"courier-pt-6"),children:[(m==null?void 0:m.headerStyle)==="border"&&(0,ze.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:m.brandColor}}),m!=null&&m.logo?(0,ze.jsx)("img",{src:m.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,ze.jsx)(Yb,{onFileSelect:P})]}),(0,ze.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,ze.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,ze.jsx)(wa,{value:v!=null?v:(E=(w=(k=(T=(I=(x=s==null?void 0:s.data)==null?void 0:x.tenant)==null?void 0:I.brand)==null?void 0:T.settings)==null?void 0:k.email)==null?void 0:w.footer)==null?void 0:E.markdown,variables:r,facebookLink:m==null?void 0:m.facebookLink,linkedinLink:m==null?void 0:m.linkedinLink,instagramLink:m==null?void 0:m.instagramLink,mediumLink:m==null?void 0:m.mediumLink,xLink:m==null?void 0:m.xLink,onUpdate:C})})]})}),(0,ze.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,ze.jsx)("div",{className:"courier-p-4 courier-h-full",children:f&&(0,ze.jsx)(r2,{})})})]})]})}),o2=(0,xn.memo)(Uv);var sp=require("react/jsx-runtime"),zv=(0,Kt.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,...n},i)=>{let s=(0,Xo.useAtomValue)(be),l=(0,Kt.useRef)(!0),c=(0,Xo.useAtomValue)(Vt),{getTemplate:u,saveBrand:d}=Wi(),[f,m]=(0,Xo.useAtom)(Tt),p=(0,Xo.useSetAtom)(Co),v=(0,Xo.useAtomValue)(Co),[h,g]=(0,Xo.useAtom)(_o),C=(0,Kt.useRef)(!1),P=(0,Xo.useSetAtom)(ae);(0,Kt.useEffect)(()=>{var x,I;f&&c!==((I=(x=f==null?void 0:f.data)==null?void 0:x.tenant)==null?void 0:I.tenantId)&&(m(null),p(null),l.current=!1)},[f,c,m,p]);let y=(0,Kt.useCallback)(async x=>{await d(x)},[d]),b=(0,Kt.useCallback)(()=>{P(Oo("Error saving theme"))},[P]),{handleAutoSave:A}=Na({onSave:y,enabled:s!==null&&r&&v!==null,debounceMs:t,onError:b});return(0,Kt.useEffect)(()=>{!c||s||f&&s===!1||u()},[c,u,s,f]),(0,Kt.useEffect)(()=>{v&&setTimeout(()=>{C.current=!0},500)},[v]),(0,Kt.useEffect)(()=>{if(!C.current||!h)return;let x={colors:{primary:h==null?void 0:h.brandColor,secondary:h==null?void 0:h.textColor,tertiary:h==null?void 0:h.subtleColor},email:{header:{barColor:(h==null?void 0:h.headerStyle)==="border"?h==null?void 0:h.brandColor:"",logo:{href:h==null?void 0:h.link,image:h==null?void 0:h.logo}},footer:{markdown:v!=null?v:void 0,social:{facebook:{url:h==null?void 0:h.facebookLink},instagram:{url:h==null?void 0:h.instagramLink},linkedin:{url:h==null?void 0:h.linkedinLink},medium:{url:h==null?void 0:h.mediumLink},twitter:{url:h==null?void 0:h.xLink}}}}};A(x)},[h,v,A]),(0,Kt.useEffect)(()=>{s||(l.current=!1)},[s]),(0,Kt.useEffect)(()=>{var x,I,T,k,w,E,N,M,S,D,L,B,V,O,j,W,_,Q,re,ee,F,G,ce,ge,fe,Ne,mt,ue,Re,ke,nt,it,Yt,Xt,at,pt,yr,Qt;if(!h){let ie=(T=(I=(x=f==null?void 0:f.data)==null?void 0:x.tenant)==null?void 0:I.brand)==null?void 0:T.settings,vr=(N=v==null?void 0:v.split(`
220
- `))!=null?N:(E=(w=(k=ie==null?void 0:ie.email)==null?void 0:k.footer)==null?void 0:w.markdown)==null?void 0:E.split(`
221
- `),Xr=vr==null?void 0:vr.find(Qr=>Qr.includes("{{urls.preferences}}"));g({brandColor:((M=ie==null?void 0:ie.colors)==null?void 0:M.primary)||br.brandColor,textColor:((S=ie==null?void 0:ie.colors)==null?void 0:S.secondary)||br.textColor,subtleColor:((D=ie==null?void 0:ie.colors)==null?void 0:D.tertiary)||br.subtleColor,headerStyle:(B=(L=ie==null?void 0:ie.email)==null?void 0:L.header)!=null&&B.barColor?"border":"plain",logo:((j=(O=(V=ie==null?void 0:ie.email)==null?void 0:V.header)==null?void 0:O.logo)==null?void 0:j.image)||br.logo,link:((Q=(_=(W=ie==null?void 0:ie.email)==null?void 0:W.header)==null?void 0:_.logo)==null?void 0:Q.href)||br.link,facebookLink:((G=(F=(ee=(re=ie==null?void 0:ie.email)==null?void 0:re.footer)==null?void 0:ee.social)==null?void 0:F.facebook)==null?void 0:G.url)||br.facebookLink,linkedinLink:((Ne=(fe=(ge=(ce=ie==null?void 0:ie.email)==null?void 0:ce.footer)==null?void 0:ge.social)==null?void 0:fe.linkedin)==null?void 0:Ne.url)||br.linkedinLink,instagramLink:((ke=(Re=(ue=(mt=ie==null?void 0:ie.email)==null?void 0:mt.footer)==null?void 0:ue.social)==null?void 0:Re.instagram)==null?void 0:ke.url)||br.instagramLink,mediumLink:((Xt=(Yt=(it=(nt=ie==null?void 0:ie.email)==null?void 0:nt.footer)==null?void 0:it.social)==null?void 0:Yt.medium)==null?void 0:Xt.url)||br.mediumLink,xLink:((Qt=(yr=(pt=(at=ie==null?void 0:ie.email)==null?void 0:at.footer)==null?void 0:pt.social)==null?void 0:yr.twitter)==null?void 0:Qt.url)||br.xLink,isPreferences:!!Xr})}},[f,g,v,h]),(0,sp.jsx)(Er,{theme:o,isLoading:!!(s&&l.current),children:(0,sp.jsx)(o2,{ref:i,hidePublish:e,...n})})}),lp=(0,Kt.memo)(zv);var _n=require("react/jsx-runtime"),n2=a((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["slack","email","sms","push","inbox"]},"resolveChannels"),_v=a(({theme:e,value:t=null,onChange:r,variables:o,hidePublish:n=!1,autoSave:i=!0,autoSaveDebounce:s=500,brandEditor:l=!1,brandProps:c,channels:u,routing:d,...f})=>{let{store:m}=Bi(),p=(0,xt.useAtomValue)(be),v=(0,xt.useAtomValue)(cr),h=(0,xt.useAtomValue)(ae),[g,C]=(0,xt.useAtom)(Tt),P=(0,xt.useAtomValue)(go),y=(0,xt.useAtomValue)(Vt),[b,A]=(0,xt.useAtom)(Yn),{getTemplate:x,saveTemplate:I,setTemplateError:T}=Ui(),k=(0,xt.useAtomValue)(ta),w=(0,We.useRef)(!1),[E,N]=(0,xt.useAtom)(se),[M,S]=(0,xt.useAtom)(Ut);(0,We.useEffect)(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=E)},[E]);let D=(0,xt.useSetAtom)(Co),L=(0,xt.useSetAtom)(_o),[B,V]=(0,xt.useAtom)(kn),O=(0,xt.useSetAtom)(be),j=n2(d,u),[W,_]=(0,We.useState)(j),Q=(0,We.useRef)(JSON.stringify(j));(0,We.useEffect)(()=>{let ue=n2(d,u),Re=JSON.stringify(ue);Re!==Q.current&&(_(ue),Q.current=Re,ue.length&&!ue.includes(B)&&V(ue[0]))},[d,u,B,V]),(0,We.useEffect)(()=>{var Re;if(p||!(E!=null&&E.elements))return;let ue=E.elements.filter(ke=>ke.type==="channel").map(ke=>ke.channel);if(!ue.includes(B)){let ke=(Re=d==null?void 0:d.channels)==null?void 0:Re.find(nt=>ue.includes(nt));!ke&&ue.length>0&&(ke=ue[0]),ke&&V(ke)}},[E,B,V,d==null?void 0:d.channels,p]),(0,We.useEffect)(()=>{var Re;let ue=(Re=g==null?void 0:g.data)==null?void 0:Re.tenant;P&&ue&&!(ue!=null&&ue.notification)&&p===!1&&(W!=null&&W.length)&&V(W[0])},[P,g,p,W,V]);let re=(0,We.useRef)(null);(0,We.useEffect)(()=>{re.current&&(re.current.templateId!==P||re.current.tenantId!==y)&&P&&y&&(S(!0),w.current=!1,C(null),N(null),D(null),L(null),A(null),V((W==null?void 0:W[0])||"email"),O(null)),P&&y&&(re.current={templateId:P,tenantId:y})},[P,y,W,S,C,N,D,L,A,V,O]);let ee=(0,We.useRef)(d);(0,We.useEffect)(()=>{ee.current=d},[d]);let F=(0,We.useCallback)(async ue=>{let Re=ue==null?void 0:ue._capturedTemplateId,ke=m.get(go);if(Re&&Re!==ke)return;let{_capturedTemplateId:nt,...it}=ue;await I({routing:ee.current,content:it})},[I,m]),G=(0,We.useCallback)(()=>{T("Error saving template")},[T]),ce=(0,xt.useAtomValue)(Qn),ge=(0,We.useCallback)(()=>{kp(ce)},[ce]),{handleAutoSave:fe}=Na({onSave:F,debounceMs:s,enabled:p===!1&&i,onError:G,flushBeforeSave:ge});(0,We.useEffect)(()=>{!P||!y||p||g&&p===!1||h||x({includeBrand:l})},[P,y,l,x,p,g,h]),(0,We.useEffect)(()=>{if(!(!t||i&&p!==!1)&&JSON.stringify(Te(Qe(E)))!==JSON.stringify(Te(Qe(t))))if(N(t),!i)O(!1);else{let ue={...t,_capturedTemplateId:P};fe(ue)}},[i,t,E,N,O,fe,P,p]),(0,We.useEffect)(()=>{var ke,nt,it,Yt,Xt,at,pt;if(p!==!1)return;let ue=(it=(nt=(ke=g==null?void 0:g.data)==null?void 0:ke.tenant)==null?void 0:nt.notification)==null?void 0:it.notificationId;if(g&&ue&&ue!==P)return;let Re=t||((pt=(at=(Xt=(Yt=g==null?void 0:g.data)==null?void 0:Yt.tenant)==null?void 0:Xt.notification)==null?void 0:at.data)==null?void 0:pt.content);N(Re),setTimeout(()=>{S(!1)},100)},[g,N,p,S,P,t]),(0,We.useEffect)(()=>{v===!0&&(w.current=!1)},[v]),(0,We.useEffect)(()=>{!E||p!==!1||setTimeout(()=>{w.current=!0},1e3)},[E,B,p]),(0,We.useEffect)(()=>{w.current=!1},[B]);let Ne=(0,xt.useAtomValue)(wt),mt=(0,xt.useAtomValue)(Pp);if((0,We.useEffect)(()=>{let ue=!!Ne&&p===!1&&!M,Re=w.current&&!!E&&p===!1&&!M;if(!ue&&!Re)return;let ke=Ne||E;if(!ke||JSON.stringify(ke)===mt)return;let it={...ke,_capturedTemplateId:P};r&&(w.current=!1,r(E||ke)),fe(it)},[E,Ne,fe,p,M,P,r,mt]),l&&k==="brand")return(0,_n.jsx)(lp,{hidePublish:n,autoSave:i,templateEditor:!0,variables:o,...c});if(k==="template"&&B==="email")return(0,_n.jsx)(K5,{variables:o,theme:e,isLoading:!!p,hidePublish:n,channels:W,brandEditor:l,routing:d,...f});if(k==="template"&&B==="sms")return(0,_n.jsx)(Db,{variables:o,theme:e,hidePublish:n,channels:W,routing:d,...f});if(k==="template"&&B==="push")return(0,_n.jsx)(pb,{variables:o,theme:e,hidePublish:n,channels:W,routing:d,...f});if(k==="template"&&B==="inbox")return(0,_n.jsx)(ab,{variables:o,theme:e,hidePublish:n,channels:W,routing:d,...f});if(k==="template"&&B==="slack")return(0,_n.jsx)(kb,{theme:e,hidePublish:n,channels:W,routing:d,variables:o});if(k==="template"&&B==="msteams")return(0,_n.jsx)(_b,{theme:e,hidePublish:n,channels:W,routing:d,variables:o})},"TemplateEditorComponent"),$v=(0,We.memo)(_v);var jv=Bc,Zv=uu,qv=eu,Jv=Kc,Gv=pu,Kv=nu;
219
+ `}default:return((y=e.content)==null?void 0:y.map(Hs).join(""))||""}},"convertNodeToMarkdown");function fu(e){return e.content?e.content.map(Hs).join("").trim():""}a(fu,"convertTiptapToMarkdown");var lo=require("jotai"),hn=require("react");var Vb=require("react"),Wb=require("react/jsx-runtime"),Ob=(0,Vb.forwardRef)(({children:e},t)=>(0,Wb.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var Gr=require("react");var Ta=require("react/jsx-runtime"),Sv=["image/png","image/jpeg","image/gif","image/webp"],Ub=a(({onFileSelect:e})=>{let[t,r]=(0,Gr.useState)(!1),o=(0,Gr.useRef)(null),n=(0,Gr.useCallback)(m=>Sv.includes(m),[]),i=(0,Gr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&(r(!0),m.dataTransfer.dropEffect="copy")},[n]),s=(0,Gr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=(0,Gr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Gr.useCallback)(async m=>{try{let{dataUrl:p}=await $s(m,800);e==null||e(p),o.current&&(o.current.value="")}catch(p){console.error("Error processing image:",p),o.current&&(o.current.value="")}},[e]),u=(0,Gr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let y=Array.from(m.dataTransfer.files).find(h=>n(h.type));y&&c(y)},[c,n]),d=(0,Gr.useCallback)(m=>{var y;let p=(y=m.target.files)==null?void 0:y[0];p&&c(p)},[c]),f=(0,Gr.useCallback)(m=>{var p;m.preventDefault(),m.stopPropagation(),(p=o.current)==null||p.click()},[]);return(0,Ta.jsxs)("div",{className:D("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:s,onDrop:u,style:{pointerEvents:"all"},children:[(0,Ta.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Ta.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:f,type:"button",children:"Browse"}),(0,Ta.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var _b=require("@hookform/resolvers/zod"),wa=require("jotai"),$b=require("lucide-react"),so=require("react"),jb=require("react-hook-form");var z=require("react/jsx-runtime"),zb=a(({isActive:e,onClick:t,value:r})=>(0,z.jsx)("div",{className:D("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,z.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,z.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),Iv=a(()=>{let[e,t]=(0,wa.useAtom)(Uo),r=(0,wa.useSetAtom)(bo),o=(0,wa.useAtomValue)(Li),n=(0,so.useRef)(null),i=(0,jb.useForm)({resolver:(0,_b.zodResolver)(Fb),defaultValues:{...hr,...e},mode:"onChange"});(0,so.useEffect)(()=>{e&&i.reset(e)},[e,i]);let s=(0,so.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,so.useCallback)(d=>{var f;if(o){if(d){let p={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(p).run()}else{let p=((f=o.getJSON().content)==null?void 0:f.filter(y=>{var v;return y.type!=="paragraph"?!0:!((v=y.content)==null?void 0:v.some(C=>{var P;return C.type==="text"&&((P=C.marks)==null?void 0:P.some(b=>{var g;return b.type==="link"&&((g=b.attrs)==null?void 0:g.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).run()}r(fu(o.getJSON()))}},[o,r]),c=(0,so.useMemo)(()=>{var d,f;return((f=(d=o==null?void 0:o.extensionManager.extensions.find(m=>m.name==="variableSuggestion"))==null?void 0:d.options)==null?void 0:f.variables)||{}},[o]),u=(0,so.useMemo)(()=>zr(c),[c]);return(0,z.jsx)(et,{...i,children:(0,z.jsx)("form",{onChange:()=>s(),children:(0,z.jsxs)("div",{className:"courier-pb-6",children:[(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,z.jsx)(X,{control:i.control,name:"headerStyle",render:({field:d})=>(0,z.jsxs)(K,{className:"courier-mb-4",children:[(0,z.jsx)(Y,{children:(0,z.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,z.jsx)(zb,{isActive:d.value==="plain",onClick:()=>{d.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,z.jsx)(zb,{isActive:d.value==="border",onClick:()=>{d.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(be,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,z.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,z.jsx)(Ve,{onClick:()=>{let d=i.getValues();d.logo="",i.reset(d),t({...d}),n.current&&(n.current.value=""),s()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,z.jsxs)(Ve,{onClick:d=>{d.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,z.jsx)($b.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,z.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async d=>{var m;let f=(m=d.target.files)==null?void 0:m[0];if(f)try{let{dataUrl:p}=await $s(f,800),y=i.getValues();y.logo=p,i.reset(y),t({...y})}catch(p){console.error("Error processing image:",p)}n.current&&(n.current.value="")}})]}),(0,z.jsx)(X,{control:i.control,name:"link",render:({field:d})=>(0,z.jsxs)(K,{className:"courier-mb-3",children:[(0,z.jsx)(Y,{children:(0,z.jsx)(Pr,{as:"Textarea",placeholder:"Link",...d,variables:u,onChange:f=>{d.onChange(f),s()}})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(be,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,z.jsx)(X,{control:i.control,name:"brandColor",render:({field:d})=>(0,z.jsxs)(K,{className:"courier-mb-4",children:[(0,z.jsx)(Y,{children:(0,z.jsx)(Et,{...d,defaultValue:d.value,onChange:f=>{d.onChange(f),s()}})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(be,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,z.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,z.jsx)(X,{control:i.control,name:"facebookLink",render:({field:d})=>(0,z.jsxs)(K,{children:[(0,z.jsx)(Y,{children:(0,z.jsx)(ye,{startAdornment:(0,z.jsx)(Ha,{}),placeholder:"facebook.com/username",...d,autoFocus:!0})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(X,{control:i.control,name:"linkedinLink",render:({field:d})=>(0,z.jsxs)(K,{children:[(0,z.jsx)(Y,{children:(0,z.jsx)(ye,{startAdornment:(0,z.jsx)(Oa,{}),placeholder:"linkedin.com/username",...d})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(X,{control:i.control,name:"instagramLink",render:({field:d})=>(0,z.jsxs)(K,{children:[(0,z.jsx)(Y,{children:(0,z.jsx)(ye,{startAdornment:(0,z.jsx)(Va,{}),placeholder:"instagram.com/username",...d})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(X,{control:i.control,name:"mediumLink",render:({field:d})=>(0,z.jsxs)(K,{children:[(0,z.jsx)(Y,{children:(0,z.jsx)(ye,{startAdornment:(0,z.jsx)(Wa,{}),placeholder:"medium.com/username",...d})}),(0,z.jsx)(Q,{})]})}),(0,z.jsx)(X,{control:i.control,name:"xLink",render:({field:d})=>(0,z.jsxs)(K,{children:[(0,z.jsx)(Y,{children:(0,z.jsx)(ye,{startAdornment:(0,z.jsx)(ja,{}),placeholder:"x.com/username",...d})}),(0,z.jsx)(Q,{})]})})]}),(0,z.jsx)(be,{className:"courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,z.jsx)(X,{control:i.control,name:"isPreferences",render:({field:d})=>(0,z.jsxs)(K,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,z.jsx)(Y,{children:(0,z.jsx)(Ui,{checked:d.value,onCheckedChange:f=>{i.setValue("isPreferences",f),d.onChange(f),l(f);let m={...i.getValues(),isPreferences:f};t(m)}})}),(0,z.jsx)(Oo,{className:"!courier-m-0",children:"Manage Preferences"}),(0,z.jsx)(Q,{})]})})]})})})},"SideBarComponent"),Zb=(0,so.memo)(Iv);var Ue=require("react/jsx-runtime"),Lv=(0,hn.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var g,N,T,R,E,w,k,x;let n=(0,lo.useSetAtom)(Ji),{publishBrand:i}=Ri(),s=(0,lo.useAtomValue)(Tt),l=(0,lo.useAtomValue)(lr),c=(0,lo.useAtomValue)(Ot),u=(0,lo.useAtomValue)(ge),d=(0,lo.useAtomValue)(ae),f=(0,lo.useAtomValue)(Li),[m,p]=(0,lo.useAtom)(Uo),[y,h]=(0,lo.useAtom)(bo),v=(0,hn.useCallback)(()=>{i()},[i]),C=(0,hn.useCallback)(({editor:A})=>{h(fu(A.getJSON()))},[h]),P=(0,hn.useCallback)(A=>{p(M=>M?{...M,logo:A}:{...hr,logo:A})},[p]),b=(0,hn.useCallback)(()=>{n("template")},[n]);return(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,Ue.jsxs)(Ob,{children:[(0,Ue.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&(0,Ue.jsx)(qi,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&(0,Ue.jsx)(Ve,{variant:"outline",buttonSize:"small",onClick:b,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&(0,Ue.jsx)(Ve,{variant:"primary",buttonSize:"small",disabled:!((N=(g=s==null?void 0:s.data)==null?void 0:g.tenant)!=null&&N.brand)||l===!0||c!==!1,onClick:v,children:l?"Publishing...":"Publish changes"})]})]})}),(0,Ue.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Ue.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Ue.jsxs)("div",{className:"courier-editor-container",ref:o,children:[(0,Ue.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,Ue.jsxs)("div",{className:D("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(m==null?void 0:m.headerStyle)==="border"&&"courier-pt-6"),children:[(m==null?void 0:m.headerStyle)==="border"&&(0,Ue.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:m.brandColor}}),m!=null&&m.logo?(0,Ue.jsx)("img",{src:m.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,Ue.jsx)(Ub,{onFileSelect:P})]}),(0,Ue.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,Ue.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,Ue.jsx)(ha,{value:y!=null?y:(x=(k=(w=(E=(R=(T=s==null?void 0:s.data)==null?void 0:T.tenant)==null?void 0:R.brand)==null?void 0:E.settings)==null?void 0:w.email)==null?void 0:k.footer)==null?void 0:x.markdown,variables:r,facebookLink:m==null?void 0:m.facebookLink,linkedinLink:m==null?void 0:m.linkedinLink,instagramLink:m==null?void 0:m.instagramLink,mediumLink:m==null?void 0:m.mediumLink,xLink:m==null?void 0:m.xLink,onUpdate:C})})]})}),(0,Ue.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Ue.jsx)("div",{className:"courier-p-4 courier-h-full",children:f&&(0,Ue.jsx)(Zb,{})})})]})]})}),qb=(0,hn.memo)(Lv);var rp=require("react/jsx-runtime"),Rv=(0,Kt.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,...n},i)=>{let s=(0,Yo.useAtomValue)(ge),l=(0,Kt.useRef)(!0),c=(0,Yo.useAtomValue)(Vt),{getTemplate:u,saveBrand:d}=Ri(),[f,m]=(0,Yo.useAtom)(Tt),p=(0,Yo.useSetAtom)(bo),y=(0,Yo.useAtomValue)(bo),[h,v]=(0,Yo.useAtom)(Uo),C=(0,Kt.useRef)(!1),P=(0,Yo.useSetAtom)(ae);(0,Kt.useEffect)(()=>{var T,R;f&&c!==((R=(T=f==null?void 0:f.data)==null?void 0:T.tenant)==null?void 0:R.tenantId)&&(m(null),p(null),l.current=!1)},[f,c,m,p]);let b=(0,Kt.useCallback)(async T=>{await d(T)},[d]),g=(0,Kt.useCallback)(()=>{P(Fo("Error saving theme"))},[P]),{handleAutoSave:N}=xa({onSave:b,enabled:s!==null&&r&&y!==null,debounceMs:t,onError:g});return(0,Kt.useEffect)(()=>{!c||s||f&&s===!1||u()},[c,u,s,f]),(0,Kt.useEffect)(()=>{y&&setTimeout(()=>{C.current=!0},500)},[y]),(0,Kt.useEffect)(()=>{if(!C.current||!h)return;let T={colors:{primary:h==null?void 0:h.brandColor,secondary:h==null?void 0:h.textColor,tertiary:h==null?void 0:h.subtleColor},email:{header:{barColor:(h==null?void 0:h.headerStyle)==="border"?h==null?void 0:h.brandColor:"",logo:{href:h==null?void 0:h.link,image:h==null?void 0:h.logo}},footer:{markdown:y!=null?y:void 0,social:{facebook:{url:h==null?void 0:h.facebookLink},instagram:{url:h==null?void 0:h.instagramLink},linkedin:{url:h==null?void 0:h.linkedinLink},medium:{url:h==null?void 0:h.mediumLink},twitter:{url:h==null?void 0:h.xLink}}}}};N(T)},[h,y,N]),(0,Kt.useEffect)(()=>{s||(l.current=!1)},[s]),(0,Kt.useEffect)(()=>{var T,R,E,w,k,x,A,M,S,L,I,B,F,U,W,O,$,Z,te,ee,V,q,ce,fe,me,Me,mt,de,Ie,Pe,nt,it,Yt,Xt,at,pt,br,Qt;if(!h){let ie=(E=(R=(T=f==null?void 0:f.data)==null?void 0:T.tenant)==null?void 0:R.brand)==null?void 0:E.settings,yr=(A=y==null?void 0:y.split(`
220
+ `))!=null?A:(x=(k=(w=ie==null?void 0:ie.email)==null?void 0:w.footer)==null?void 0:k.markdown)==null?void 0:x.split(`
221
+ `),Kr=yr==null?void 0:yr.find(Yr=>Yr.includes("{{urls.preferences}}"));v({brandColor:((M=ie==null?void 0:ie.colors)==null?void 0:M.primary)||hr.brandColor,textColor:((S=ie==null?void 0:ie.colors)==null?void 0:S.secondary)||hr.textColor,subtleColor:((L=ie==null?void 0:ie.colors)==null?void 0:L.tertiary)||hr.subtleColor,headerStyle:(B=(I=ie==null?void 0:ie.email)==null?void 0:I.header)!=null&&B.barColor?"border":"plain",logo:((W=(U=(F=ie==null?void 0:ie.email)==null?void 0:F.header)==null?void 0:U.logo)==null?void 0:W.image)||hr.logo,link:((Z=($=(O=ie==null?void 0:ie.email)==null?void 0:O.header)==null?void 0:$.logo)==null?void 0:Z.href)||hr.link,facebookLink:((q=(V=(ee=(te=ie==null?void 0:ie.email)==null?void 0:te.footer)==null?void 0:ee.social)==null?void 0:V.facebook)==null?void 0:q.url)||hr.facebookLink,linkedinLink:((Me=(me=(fe=(ce=ie==null?void 0:ie.email)==null?void 0:ce.footer)==null?void 0:fe.social)==null?void 0:me.linkedin)==null?void 0:Me.url)||hr.linkedinLink,instagramLink:((Pe=(Ie=(de=(mt=ie==null?void 0:ie.email)==null?void 0:mt.footer)==null?void 0:de.social)==null?void 0:Ie.instagram)==null?void 0:Pe.url)||hr.instagramLink,mediumLink:((Xt=(Yt=(it=(nt=ie==null?void 0:ie.email)==null?void 0:nt.footer)==null?void 0:it.social)==null?void 0:Yt.medium)==null?void 0:Xt.url)||hr.mediumLink,xLink:((Qt=(br=(pt=(at=ie==null?void 0:ie.email)==null?void 0:at.footer)==null?void 0:pt.social)==null?void 0:br.twitter)==null?void 0:Qt.url)||hr.xLink,isPreferences:!!Kr})}},[f,v,y,h]),(0,rp.jsx)(wr,{theme:o,isLoading:!!(s&&l.current),children:(0,rp.jsx)(qb,{ref:i,hidePublish:e,...n})})}),op=(0,Kt.memo)(Rv);var Wn=require("react/jsx-runtime"),Jb=a((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["slack","email","sms","push","inbox"]},"resolveChannels"),Dv=a(({theme:e,value:t=null,onChange:r,variables:o,hidePublish:n=!1,autoSave:i=!0,autoSaveDebounce:s=500,brandEditor:l=!1,brandProps:c,channels:u,routing:d,...f})=>{let{store:m}=Ni(),p=(0,xt.useAtomValue)(ge),y=(0,xt.useAtomValue)(lr),h=(0,xt.useAtomValue)(ae),[v,C]=(0,xt.useAtom)(Tt),P=(0,xt.useAtomValue)(uo),b=(0,xt.useAtomValue)(Vt),[g,N]=(0,xt.useAtom)(Zn),{getTemplate:T,saveTemplate:R,setTemplateError:E}=Di(),w=(0,xt.useAtomValue)(Ji),k=(0,Oe.useRef)(!1),[x,A]=(0,xt.useAtom)(se),[M,S]=(0,xt.useAtom)(Ut);(0,Oe.useEffect)(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=x)},[x]);let L=(0,xt.useSetAtom)(bo),I=(0,xt.useSetAtom)(Uo),[B,F]=(0,xt.useAtom)(xn),U=(0,xt.useSetAtom)(ge),W=Jb(d,u),[O,$]=(0,Oe.useState)(W),Z=(0,Oe.useRef)(JSON.stringify(W));(0,Oe.useEffect)(()=>{let de=Jb(d,u),Ie=JSON.stringify(de);Ie!==Z.current&&($(de),Z.current=Ie,de.length&&!de.includes(B)&&F(de[0]))},[d,u,B,F]),(0,Oe.useEffect)(()=>{var Ie;if(p||!(x!=null&&x.elements))return;let de=x.elements.filter(Pe=>Pe.type==="channel").map(Pe=>Pe.channel);if(!de.includes(B)){let Pe=(Ie=d==null?void 0:d.channels)==null?void 0:Ie.find(nt=>de.includes(nt));!Pe&&de.length>0&&(Pe=de[0]),Pe&&F(Pe)}},[x,B,F,d==null?void 0:d.channels,p]),(0,Oe.useEffect)(()=>{var Ie;let de=(Ie=v==null?void 0:v.data)==null?void 0:Ie.tenant;P&&de&&!(de!=null&&de.notification)&&p===!1&&(O!=null&&O.length)&&F(O[0])},[P,v,p,O,F]);let te=(0,Oe.useRef)(null);(0,Oe.useEffect)(()=>{te.current&&(te.current.templateId!==P||te.current.tenantId!==b)&&P&&b&&(S(!0),k.current=!1,C(null),A(null),L(null),I(null),N(null),F((O==null?void 0:O[0])||"email"),U(null)),P&&b&&(te.current={templateId:P,tenantId:b})},[P,b,O,S,C,A,L,I,N,F,U]);let ee=(0,Oe.useRef)(d);(0,Oe.useEffect)(()=>{ee.current=d},[d]);let V=(0,Oe.useCallback)(async de=>{let Ie=de==null?void 0:de._capturedTemplateId,Pe=m.get(uo);if(Ie&&Ie!==Pe)return;let{_capturedTemplateId:nt,...it}=de;await R({routing:ee.current,content:it})},[R,m]),q=(0,Oe.useCallback)(()=>{E("Error saving template")},[E]),ce=(0,xt.useAtomValue)(Jn),fe=(0,Oe.useCallback)(()=>{fp(ce)},[ce]),{handleAutoSave:me}=xa({onSave:V,debounceMs:s,enabled:p===!1&&i,onError:q,flushBeforeSave:fe});(0,Oe.useEffect)(()=>{!P||!b||p||v&&p===!1||h||T({includeBrand:l})},[P,b,l,T,p,v,h]),(0,Oe.useEffect)(()=>{if(!(!t||i&&p!==!1)&&JSON.stringify(Ce(Qe(x)))!==JSON.stringify(Ce(Qe(t))))if(A(t),!i)U(!1);else{let de={...t,_capturedTemplateId:P};me(de)}},[i,t,x,A,U,me,P,p]),(0,Oe.useEffect)(()=>{var Pe,nt,it,Yt,Xt,at,pt;if(p!==!1)return;let de=(it=(nt=(Pe=v==null?void 0:v.data)==null?void 0:Pe.tenant)==null?void 0:nt.notification)==null?void 0:it.notificationId;if(v&&de&&de!==P)return;let Ie=t||((pt=(at=(Xt=(Yt=v==null?void 0:v.data)==null?void 0:Yt.tenant)==null?void 0:Xt.notification)==null?void 0:at.data)==null?void 0:pt.content);A(Ie),setTimeout(()=>{S(!1)},100)},[v,A,p,S,P,t]),(0,Oe.useEffect)(()=>{y===!0&&(k.current=!1)},[y]),(0,Oe.useEffect)(()=>{!x||p!==!1||setTimeout(()=>{k.current=!0},1e3)},[x,B,p]),(0,Oe.useEffect)(()=>{k.current=!1},[B]);let Me=(0,xt.useAtomValue)(lt),mt=(0,xt.useAtomValue)(pp);if((0,Oe.useEffect)(()=>{let de=!!Me&&p===!1&&!M,Ie=k.current&&!!x&&p===!1&&!M;if(!de&&!Ie)return;let Pe=Me||x;if(!Pe||JSON.stringify(Pe)===mt)return;let it={...Pe,_capturedTemplateId:P};r&&(k.current=!1,r(x||Pe)),me(it)},[x,Me,me,p,M,P,r,mt]),l&&w==="brand")return(0,Wn.jsx)(op,{hidePublish:n,autoSave:i,templateEditor:!0,variables:o,...c});if(w==="template"&&B==="email")return(0,Wn.jsx)(W5,{variables:o,theme:e,isLoading:!!p,hidePublish:n,channels:O,brandEditor:l,routing:d,...f});if(w==="template"&&B==="sms")return(0,Wn.jsx)(Eb,{variables:o,theme:e,hidePublish:n,channels:O,routing:d,...f});if(w==="template"&&B==="push")return(0,Wn.jsx)(ob,{variables:o,theme:e,hidePublish:n,channels:O,routing:d,...f});if(w==="template"&&B==="inbox")return(0,Wn.jsx)(K5,{variables:o,theme:e,hidePublish:n,channels:O,routing:d,...f});if(w==="template"&&B==="slack")return(0,Wn.jsx)(hb,{theme:e,hidePublish:n,channels:O,routing:d,variables:o});if(w==="template"&&B==="msteams")return(0,Wn.jsx)(Rb,{theme:e,hidePublish:n,channels:O,routing:d,variables:o})},"TemplateEditorComponent"),Bv=(0,Oe.memo)(Dv);var Hv=Lc,Fv=au,Vv=Kc,Ov=Zc,Wv=cu,Uv=eu;
222
222
  //# sourceMappingURL=index.js.map